467,074 Members | 1,093 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

Adding up hours and minutes problem

Hi Folks,

We have a form that records flight times in hours and minutes, for example a
1 hour 15 minute flight is recorded as 1:15 Does anyone know how to get
Access 2003 to calculate a total figure for a number of flight times
recorded in a datasheet form? and is there a way to display flight times
greater than 24 hours i.e 26:20 for example? The only solution i can find is
to use decimal times i.e 1.25 instead of 1:15 which is our least preferred
solution.

Many thanks

Nige
Feb 20 '07 #1
  • viewed: 5009
Share:
3 Replies
"Nigel Heald" <ni***@mrauk.co.ukwrote in
news:12*************@corp.supernews.com:
Hi Folks,

We have a form that records flight times in hours and minutes, for
example a 1 hour 15 minute flight is recorded as 1:15 Does anyone know
how to get Access 2003 to calculate a total figure for a number of
flight times recorded in a datasheet form? and is there a way to
display flight times greater than 24 hours i.e 26:20 for example? The
only solution i can find is to use decimal times i.e 1.25 instead of
1:15 which is our least preferred solution.

Many thanks

Nige
You could write User Defined Functions. Here are a couple, thoroughly
untested, that might be a start:

Sub temp()
Debug.Print TimetoMinutes("1:15") + TimetoMinutes("23:00")
End Sub

Public Function HoursandMinutes$(ByVal vNinutes As Date)
Dim DateZero As Date
Dim Ninutes&
DateZero = DateSerial(1899, 12, 30)
Ninutes = DateDiff("n", DateZero, vNinutes)
HoursandMinutes = CStr(Ninutes \ 60) & ":" & CStr(Ninutes Mod 60)
End Function

Public Function TimetoMinutes#(ByVal vTime$)
' vtime must be in format #0:00
TimetoMinutes = CDbl(Replace(vTime, ":", "."))
End Function
Feb 20 '07 #2
See:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nigel Heald" <ni***@mrauk.co.ukwrote in message
news:12*************@corp.supernews.com...
Hi Folks,

We have a form that records flight times in hours and minutes, for example
a 1 hour 15 minute flight is recorded as 1:15 Does anyone know how to get
Access 2003 to calculate a total figure for a number of flight times
recorded in a datasheet form? and is there a way to display flight times
greater than 24 hours i.e 26:20 for example? The only solution i can find
is to use decimal times i.e 1.25 instead of 1:15 which is our least
preferred solution.

Many thanks

Nige
Feb 20 '07 #3
Nigel

Had a quick go at this.
I think you will need to have the "flight time" field as a text type to
accomadate the +24 time flights.
You can then use CDbl(Left("Flight Time",2)) to convert the hours and
CDbl(Mid("Flight Time",4,2) to convert the minutes.
Get the complete total of minutes and divide by 60 to get the total hours.
Get the remainder and times by 60 to get the total minutes (or times by 6 if
you dont use the decimal).
However I started running into problems when the number of hours was more
than two digits long as it messes up the Left and Mid functions. Would be
easier if there is a way to detect the ":".

Sorry if this hasn't helped, lol.

Thanks
Paul

"Nigel Heald" <ni***@mrauk.co.ukwrote in message
news:12*************@corp.supernews.com...
Hi Folks,

We have a form that records flight times in hours and minutes, for example
a 1 hour 15 minute flight is recorded as 1:15 Does anyone know how to get
Access 2003 to calculate a total figure for a number of flight times
recorded in a datasheet form? and is there a way to display flight times
greater than 24 hours i.e 26:20 for example? The only solution i can find
is to use decimal times i.e 1.25 instead of 1:15 which is our least
preferred solution.

Many thanks

Nige

Feb 20 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Nicolas Mejia | last post: by
22 posts views Thread by Drum2001 | last post: by
1 post views Thread by baneaic@yahoo.com | last post: by
1 post views Thread by Nigel Heald | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.