Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing Dates with a condition

Status
Not open for further replies.
Mar 2, 2006
37
US
Hello,

I'm doing calculations on date fields and I need to use the if or Iff
condition. I've never used it before. Can anybody help me on accomplishing
this? Does it have to be done in Visual Basics or can I do it at the query
design view?

Below are examples on what the data looks like,

Start Time
4/3/2006 7:57:00 PM
4/3/2006 9:00:00 PM

ReceivedOn
4/3/2006 8:56:59 PM
4/3/2006 5:18:55 PM

ValidatedTime
4/3/2006 8:57:07 PM
4/3/2006 9:01:01 PM

If StartTime is after (>) than ReceivedOn then, Latency= ValidatedTime-
StartTime

Otherwise, Latency=ValidatedTime-ReceivedOn

Thanks,

Rita

 
I think it will look like

Latency: If CDate([StartTime]) > CDate([ReceivedOn]) then

DateDiff('s',[Validated],[StartTime]) else

DateDiff('s',[Validated],[ReceivedOn])
 
Code:
[ValidatedTime] - IIF([StartTime]>[ReceivedOn],[StartTime],[ReceivedOn])

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Thanks for your prompt response.

What If I change it to this? Is the syntax alright?

Latency: IIf([StartTime]>[ReceivedOn], (DateDiff('s',[Validated],[StartTime]),[ReceivedOn])), DateDiff('s',[Validated],[ReceivedOn])
 
Try this
Code:
Latency: DateDiff('s',[Validated],
         IIf([StartTime]>[ReceivedOn],[StartTime],[ReceivedOn]))

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top