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

Interval between two date/time fields 2

Status
Not open for further replies.

mguidry5

Technical User
Jan 11, 2005
91
US
Simple query: I need to determine the interval (in hours:minutes:seconds) between two date/time fields, StartDate and EndDate.
 
Code:
NewTime = Format(DateDiff("s",StartDate,EndDate),"hh:nn:ss")

The format part may work though I have never tried it. If not, still use the datediff function to get the time interval in seconds then build that into hours minutes and seconds.

mike
 
If the days are the same:
Interval: Format(EndDate-StartDate,'h:nn:ss')
If not:
Interval: (24*Int(EndDate-StartDate)+Format(EndDate-StartDate,'h')) & Format(EndDate-StartDate,':nn:ss')

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV - once again, you da man! Thanks for the simple solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top