By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,488 Members | 2,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,488 IT Pros & Developers. It's quick & easy.

Adding up hours and minutes problem

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
"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

P: n/a
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

P: n/a
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.