Conditional Statement with dates

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Conditional Statement with dates

Post by Leesha »

Hi,

I have query using the following conditional statement:

Timely: IIf([r_posocroc]>[soc_dt],"late","Timely")

Both fields are date fields. The query is not returning the info correctly. For example, in one case r_posocroc = 11/1/2011 and the SOC date = 3/1/2011 and its stating that its "timely" when in fact it should be "late". Am I missing anything in the statement?

Thanks,
Leesah

User avatar
HansV
Administrator
Posts: 78393
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Conditional Statement with dates

Post by HansV »

The expression looks OK. Are you absolutely sure about the dates? For example if r_posocroc were 11/1/2010 instead of 11/1/2011, you'd get "timely".
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Conditional Statement with dates

Post by Leesha »

Hi Hans,

I checked the format directly in the tables and they are set to date. I tried Timely: DateDiff("d",[r_posocroc],[socdate]) and the numbers come up correctly for the difference in days. I can use this as a work around, but just couldn't figure out why the conditional statement wasn't working. Unfortunately its a huge DB with SQL linked tables so there's really no way to strip down and upload.
Thanks,
Leesha

User avatar
HansV
Administrator
Posts: 78393
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Conditional Statement with dates

Post by HansV »

I understand why it is impossible to attach a sample of the data, but I have no further ideas without seeing them.
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Conditional Statement with dates

Post by Leesha »

I appreciate the help by looking at the statement.

Leesha