Link to home
Start Free TrialLog in
Avatar of CompTech810
CompTech810Flag for United States of America

asked on

Compare Dates

Hi Experts:

The problem that I am running into is: I'm comparing two dates and if the date field (NEWWE) is less than PASTWE date plus thirteen weeks it should display the NEWWE date else display zero.  It is working for the most part but a NEWWE date of 09/18/2011 < 12/11/2011 is returning a value of 0 when it should return the NEWWE value.  The following is the Iif statement I'm using.

IIf([NewWe]<DateAdd("ww",13,[PASTWE]),[NewWe],0)

What am I doing wrong?  Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Cluskitt
Cluskitt
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CompTech810

ASKER

Ahh...  That worked with the exception of the '0' displays as: 12/30/1899
Yes. A date with the value of 0 is that. You can, however, simply remove the last CDate. You only need it to compare. Afterwards, you can return it as a string. If you need the value as a date later, you can always use CDate then.
Great that worked.

I do have an additional question.  In the criteria of the query that we just did I only want to display dates that are greater than zero.  When I use the criteria to only include records greater than zero it prompts me for NEWWE.

>0
Well, without looking at your file, it's hard to know what went wrong. You can have a look at the SQL to see if anything is amiss. Without knowing what you did, I can't really help you. But if you just add:
>0
in the criteria field, I don't see a reason why it shouldn't work.
I'm not sure either.  Is there a way to run debug to check what access is doing?
I submitted a question with the criteria issue.  I have tried everything I can think of.

Thanks for your help!
Glad to help. As for the debug part, you can't really debug SQL. What you can do is check the SQL query (I assume you were doing this in the graphic structure window). Then you, or someone here, can assist you with it.
Thanks!!