add or subtract two time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please help . .

I have try this expression to calculate in query the time for my database
but i got "0:00" answer.

datediff("n",format(FieldTime1,"hh:mm"),format (FieldTime2,"hh:mm"))

onblock = 14:00
offblock = 15:20 so it must be on/off block diff = 00:40

the onblock and offblock are set in table as "short time format"

Please help im new user. . .
 
The Format() returns string data and DateDiff() wants DateTime data. Try:
datediff("n",TimeValue(format(FieldTime1,"hh:mm")),TimeValue(format
(FieldTime2,"hh:mm")))

Why not just use the field without any formatting?
datediff("n",FieldTime1,FieldTime2)

The DateTime field is *always* stored the same way. "short time format" is
simply a display format option.

Here's a link that describes the data type:
http://support.microsoft.com/default.aspx/kb/q130514/
 
Back
Top