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

Date/Time Problem 1

Status
Not open for further replies.

rgbanse

MIS
Jun 4, 2001
211
US
The Group,
I have StartDate, StartTime, StopDate, StopTime fields that I cannot change the input format on. I need the ability to calc the number of elasped hours between the StartDate/Time and the StopDate/Time. I would like to combine the dates and times in a "DateTimeValue" format to do the math, but can't seem to find the right methods. Any thoughts?
thx
RGB
 
MyStTime = #8:13 AM#
MyStDate = #1/12/02#
MyEndTime = #3:47 PM#
MyEndDate = #1/13/02#
? MyStDAte, MyStTime, MyEndDate, MyEndTime
1/12/02 8:13:00 AM 1/13/02 3:47:00 PM

? MyStDate + MyStTime
1/12/02 8:13:00 AM

? MyEndDate + MyEndTime
1/13/02 3:47:00 PM
MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Mike,
I with ya so far but need the next step
(MyEndDate + MyEndTime) - (MyStDate + MyStTime) = X Hours
01/18/02 + 14:00:00 - 01/17/02 + 10:00:00 = 28 Hours
thx
RGB
 
DateDiff ... but you need to be careful. Your example 'happens' to have oo Minutes and seconds. The "real world" is seldom so kind. DateDiff computes based on the interval BOUNDARIES, so DateDiff("h", #1/18/02 11:59 AM# #1/18/02 12:01PM#) will return one (1). In general, compute the "diff" to one level more than you need and do the division. e.g. If you want to know hours, get te 'diff' in minutes and divide by 60.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Mike - Ya did great - it works great
thx again
RGB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top