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!

still on time differences

Status
Not open for further replies.

ianvanniekerk

Technical User
Aug 11, 2002
3
ZA
The enter time is read into a textbox eg 09:24 & when the client leaves the workshop, the time is read in again, or could be automatically be put in another textbox with the NOW function (also in a short time eg 09:55). What i need is the time difference in another textbox, something like 00:31. What i could achieve was to convert the 'enter time' as well as the 'time left' to seconds, subtracting the two in another textbox, then breaking the answer down to hours(answer in seconds /3600 & rounding it down to the smaller number) then take the remainder & working out the minutes & i now have the hours in 1 textbox & the minutes in another. could these be joined into 1 textbox & tell Access that this now is seen as time? can't you simply tell Access that time left - time in = difference in time
 
MS Knowledge base has a function posted that does all this for you
just paste this in a module and off you go




Public Function GetElapsedTime(interval)
'pass as GetElapsedTime(latertime - earliertime)
Dim totalhours As Long, totalminutes As Long, totalseconds As Long
Dim days As Long, hours As Long, Minutes As Long, Seconds As Long

days = Int(CSng(interval))
totalhours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440))
totalseconds = Int(CSng(interval * 86400))
hours = totalhours Mod 24
Minutes = totalminutes Mod 60
Seconds = totalseconds Mod 60

GetElapsedTime = days & " Days " & hours & " Hours " & Minutes _
& " Minutes " & Seconds & " Seconds "

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top