Converting Integer to Time Datatype- Possible ?

  • Thread starter edisonl via AccessMonster.com
  • Start date
E

edisonl via AccessMonster.com

Hi,

Got a tricky problem here.. I had 4 Text Box(es) input for Hours & Minutes
Respectively as follows:

StartHours_Text StartMinutes_Text

EndHours_Text EndMinutes_Text
'Both have test statement for right inputs Eg: Hours Between 0-23, Minutes
Only (Mod,15)

Problem arises when I need to some minus operations to find time differences
Eg:
Start Time : 08 Hours 45Minutes
End Time : 10 Hours 15Minutes
__________________________________________________________________
Hours(1Hours) = EndHours_Text -
StartHours_Text
Minutes (30Minutes ~0.5Hours) = EndMinutes_Text - StartMinutes_Text
___________________________________________________________________

End Value: 1.5 (Decimal or ANy Datatype)
 
A

Allen Browne

You could calculate the number of minutes like this:
(60 * Nz([EndHours_Text], 0) + Nz([EndMinutes_Text], 0)) -
(60 * Nz([StartHours_Text], 0) + Nz([StartMinutes_Text] ,0))

If you want hours-and-decimial, bracket the whole thing and divide by 60.

Use integer division and Mod for hour:minute format.
Details in 5th paragraph here:
http://allenbrowne.com/casu-13.html
 
Top