Date Calculation Problem

G

Guest

I have the following query (this is a test of a larger one):

TEST: IIf([Next Gas Well Gas Sample Due]<Now(),"OVERDUE"," ")

Today's date is 3/21/2007 (which the NOW() function is displaying correctly)

Next Gas Well Gas Sample Due is a calculated field and is returning the
value 1/13/2008

My query is returning the OVERDUE statement and I can't see why? Anyone
able to help??

It should be blank, but I can't figure out the problem!
 
F

fredg

I have the following query (this is a test of a larger one):

TEST: IIf([Next Gas Well Gas Sample Due]<Now(),"OVERDUE"," ")

Today's date is 3/21/2007 (which the NOW() function is displaying correctly)

Next Gas Well Gas Sample Due is a calculated field and is returning the
value 1/13/2008

My query is returning the OVERDUE statement and I can't see why? Anyone
able to help??

It should be blank, but I can't figure out the problem!

It seems to me that 1/13/2008 is greater than (>) 3/21/2007.....

TEST: IIf([Next Gas Well Gas Sample Due] > Now(),"OVERDUE","")

Note: Now() contains a Time of Day value as well as a Date value, so
the actual returned text might be dependent upon the time of day you
run the query.
Perhaps you should use Date() instead of Now() if the time of day is
not important.
 
G

Guest

The next due calculation returns a date >NOW which means is not due yet and
therefore shouldn't return OVERDUE. Which it did.

However... I found the problem. The calculated "next gas well gas sample
due" field was an iif statement that could return both a text and date value,
which meant it defaulted the date to text which wasn't recognized in the iif
statement I submitted!

I deleted all parts of the statement so that it only returns a date and the
calculation now works!

I'm still really glad this forum is here- thanks for the help!

Thanks a bunch for the help though
fredg said:
I have the following query (this is a test of a larger one):

TEST: IIf([Next Gas Well Gas Sample Due]<Now(),"OVERDUE"," ")

Today's date is 3/21/2007 (which the NOW() function is displaying correctly)

Next Gas Well Gas Sample Due is a calculated field and is returning the
value 1/13/2008

My query is returning the OVERDUE statement and I can't see why? Anyone
able to help??

It should be blank, but I can't figure out the problem!

It seems to me that 1/13/2008 is greater than (>) 3/21/2007.....

TEST: IIf([Next Gas Well Gas Sample Due] > Now(),"OVERDUE","")

Note: Now() contains a Time of Day value as well as a Date value, so
the actual returned text might be dependent upon the time of day you
run the query.
Perhaps you should use Date() instead of Now() if the time of day is
not important.
 

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

Top