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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One Expression in a Query IF/ ELSE?

Status
Not open for further replies.

gwendon

Technical User
Apr 7, 2002
23
US
I am using ACCESS 2000 and I have a simple table with the following fields: HCHV_PROGRAM/DateIn/DateOut/TimeInProgram. Within a Query I can create a DateDiff function that will give me TimeInProgram based on DateIn minus DateOut Or DateIn minus the Current Date. But what I need is a TimeInProgram based on DateIn minus DateOut if one exists otherwise I need a TimeInProgram based on DateIn minus the Current Date. A sort of IF/ELSE in one expression, in a query, if that is possible?

 
Hi!

Yes it is possible:

IIf(IsNull([DateOut]) = True, DateDiff("dd", [DateIn], Date()), DateDiff("dd", [DateIn], [DateOut])) As TimeInProgram

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thank you very much Jeff it works great!!!
The only thing I had to change were the "dd" to "y"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top