Subtracting 12 hours from a date-time field

Ste4en

Registered User.
Local time
Today, 17:00
Joined
Sep 19, 2001
Messages
142
I am trying to subtract 12 hours from a time-date field when the payperiod does not equal 01.

in a query I have:

Code:
work date: iif([payperiod]="01",[StartTime],[starttime]-#12:00:00#)
- Access added a PM before the second hash so it looks like this:

Code:
iif([payperiod]="01",[StartTime],[starttime]-#12:00:00 PM#)

When I run the query I get a message box: "syntax error (missing operator) in query expression '00:00:PM#,2))". I am unable to open the query to correct the error. I can cop the unaltered query from a back up database.

My question is how do I subtract the 12 hours.

Thanks

Steve
 
Try:
Code:
work date:=IIF([payperiod]="01",[StartTime],DateAdd("h",-12,[starttime]))
 
Thanks - that worked.
 

Users who are viewing this thread

Back
Top Bottom