add hours (1 Viewer)

maxmangion

AWF VIP
Local time
Today, 20:04
Joined
Feb 26, 2003
Messages
2,805
Hi,

I have two fields in a query which their datatype is set to Date/Time. I am using the following to calculate their difference, and it works fine.

Format([StartTime]-1-[EndTime],"Short Time")

How can i amend the above code to deduct 8 hrs from the result returned ? i.e. if the result is 9 hrs 10 mins, i want to deduct 8 hrs so that it will display 1 hr 10 mins

Thank you for any advice.
 

namliam

The Mailman - AWF VIP
Local time
Today, 21:04
Joined
Aug 11, 2003
Messages
11,695
- 8/24
or use a time denotation
- #08:00:00#
Either will do the trick or use the Dateadd function
dateadd("H", -8, old diff)

Good luck!
 

maxmangion

AWF VIP
Local time
Today, 20:04
Joined
Feb 26, 2003
Messages
2,805
Hi

Thx for your reply. I think i have explained myself incorrectly. What i want is to deduct 8 hours from my field, but not go to eight hours before, but return the difference from mytime less 8 hours .. for example if my time was 9hrs 10 mins, i want to return the 70 mins difference when i deduct the 8 hours and not display that the new time is 13:10.

I hope i have managed to explain myself clear.

Thank you
 

maxmangion

AWF VIP
Local time
Today, 20:04
Joined
Feb 26, 2003
Messages
2,805
Thx namliam for your help, but i managed to find a solution.

i achieved it using the following:

Expr2: Hour([TimeDiff])*60+Minute([TimeDiff])-480

Thx
 

namliam

The Mailman - AWF VIP
Local time
Today, 21:04
Joined
Aug 11, 2003
Messages
11,695
I hope i have managed to explain myself clear.
Nope I dont understand...

First I am just now noticing that you shouldnt use [StartTime] - 1 - [Endtime] but [EndTime] - [StartTime] !!

If EndTime - Starttime = 9 hours 10 minutes then
EndTime - Starttime - 8 hours will be 1 hour 10 minutes or 70 minutes depending on display type.

Your solution works, but... it is kind of a round about way... Kindof like Going Amsterdam - Paris via Moscow
 

icemonster

Registered User.
Local time
Today, 14:04
Joined
Jan 30, 2010
Messages
502
ok, i had 2.5 hours per day, for 5 days should be 12.5hrs, but instead i get this

> 10.166666666667, the hours are added up correctly, 2.5 hours per day, so it counts 2*5, so 10. but the minutes, that's where its not counting.
 

silviadana

New member
Local time
Today, 12:04
Joined
Mar 9, 2010
Messages
7
ok, i had 2.5 hours per day, for 5 days should be 12.5hrs, but instead i get this

> 10.166666666667, the hours are added up correctly, 2.5 hours per day, so it counts 2*5, so 10. but the minutes, that's where its not counting.

I think you have to format the result you want
format(expresion,"hh:mm")
 

icemonster

Registered User.
Local time
Today, 14:04
Joined
Jan 30, 2010
Messages
502
sorry if posted here again, but what do you mean by delete? and post it in the right one? @_@

so what should i do? how will i add it correctly?
 

Users who are viewing this thread

Top Bottom