By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

Calculating Time when the date is changed after 12:00am

P: 194
Hi everybody. I have some problem while calculating time. i have employees who are working on hourly basis. i want to calculate the time. for example if an employee start working at 11:00pm (10-November-2008) and finish his job at 8:00am (11-November-2008) then how i can calculate the time between two different dates? i used dateDiffer method but it only displays the time difference between one date. please tell me how i can do this. thank you.

Nov 10 '08 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 375
See if this link helps.
Nov 10 '08 #2

Expert 2.5K+
P: 2,653
Format([StartTime] -1 -[EndTime], "Short Time")

Just out of curiosity...
How much time the author hadn't slept before begat this code.

Kind regards,
Nov 10 '08 #3

Expert 2.5K+
P: 3,532
"i used dateDiffer method but it only displays the time difference between one date"

That's not true, of course! DateDiff() will calculate a lapsed time between two date/times, as in the scenario described here. You don't really say whether these times are part of a single date/time field (11/8/2008 23:00) or whether you have a field for the date and a separate field for the time.

If you have a single, unified date/time field, straight DateDiff() should work fine. If LapsedHours is defined as a Double, this will give you hours and fraction of an hour:

LapsedHours = DateDiff("n",StartTime,StopTime)/60

If you have fields that only hold the time component, this formula will do the same thing:

If StartTime > StopTime Then
LapsedHours = (DateDiff("n",StartTime,StopTime) + 1440)/60
LapsedHours = (DateDiff("n",StartTime,StopTime)/60
End If

Linq ;0)>
Nov 11 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.