Date comparison

S

senkurion

Hi;

In my reort I have one text box which is autamatically calculated if the
present date is greater than or equal to specified that. I used the following
expression in control source to calculate it
=IIf(Date()>=3/31/2008,[Initial Deposit]*[Interest
rate]*0.01/[Installement],0)

For this expression I expected value 0 instead it calculates as if present
date is greater than 3/31/2008. On the otherhand if I use following
expression it returns the 0 value

=IIf(Date()<=3/31/2008,[Initial Deposit]*[Interest
rate]*0.01/[Installement],0)

(please note the difference ( > and <)
whats wrong here? and what is supposed to be the correct expression here?
Can some gurus help me??
 
R

Rick Brandt

senkurion said:
Hi;

In my reort I have one text box which is autamatically calculated if
the present date is greater than or equal to specified that. I used
the following expression in control source to calculate it
=IIf(Date()>=3/31/2008,[Initial Deposit]*[Interest
rate]*0.01/[Installement],0)

For this expression I expected value 0 instead it calculates as if
present date is greater than 3/31/2008. On the otherhand if I use
following expression it returns the 0 value

=IIf(Date()<=3/31/2008,[Initial Deposit]*[Interest
rate]*0.01/[Installement],0)

(please note the difference ( > and <)
whats wrong here? and what is supposed to be the correct expression
here? Can some gurus help me??

Date literals need to be delimited with #. Your current expression is actually
comparing Date() to the number 3 divided by 31 divided by 2008.
 
S

senkurion

Thanks for the reply. It is working now I have one more question
1. How do you ask to check the either year or month of the date field with
present date?
I tried to use following but it does not work.


IIF(Year Date()>=Year[Account Open On], [interest rate]*[Installement], 0)

to check the year of present date with that of Account Open On


Rick Brandt said:
senkurion said:
Hi;

In my reort I have one text box which is autamatically calculated if
the present date is greater than or equal to specified that. I used
the following expression in control source to calculate it
=IIf(Date()>=3/31/2008,[Initial Deposit]*[Interest
rate]*0.01/[Installement],0)

For this expression I expected value 0 instead it calculates as if
present date is greater than 3/31/2008. On the otherhand if I use
following expression it returns the 0 value

=IIf(Date()<=3/31/2008,[Initial Deposit]*[Interest
rate]*0.01/[Installement],0)

(please note the difference ( > and <)
whats wrong here? and what is supposed to be the correct expression
here? Can some gurus help me??

Date literals need to be delimited with #. Your current expression is actually
comparing Date() to the number 3 divided by 31 divided by 2008.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top