Military Time(Short Time Format)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Could someone please send or direct me to someplace where I can get a
function to handle the adding and subtracting of Military time? I am
developing a EMS Response tracking system and in all my years of coding, I
have never had to deal with the Short Time format.

Every function I have written I have eventually broke or found an error. I
am getting close to deadline and this is the only problem I need to solve
conclusively. I am using MS Access 2000/VBA

Thanks for your suggestions!
 
I'm not sure why you would ever add date/times. To me this would be like
adding six o'clock + five o'clock. Durations of time should be stored in the
same way that you would store quantities of anything else. Consider using a
numeric field to store your durations as a number of minutes or hours or
whatever.

You can however, add times that are stored as date/time fields since these
fields are actually floating point numbers. A day = 1, 12 hours = .5, 6
hours = .25. The main issue you have is when you sum these numbers and
attempt to display them using a time format which only displays a maximum of
24 hours.
 
Your right, I did not explain my problem correctly. What I am doing(trying!)
is get the correct time intervals(hours,minutes) between the time the
emergency alarm is recieved by the station, time it takes to leave, time it
takes to arrive at the scene, time at the scene, and the time of arrival back
at the station.

Then I need to calculate the total manpower hours(totaltime * number of
men). I have to use Short time format(20:40) for my input boxes. I have tried
to convert and manipulate the data but still seem to come up short of right
when I report the totals.
 
The Date/Time field (or variable) stores a Date and Time as a point in time.
If you are only entering the time... quite possibly a calculation problem as
one of your records may cross midnight... then you are saving that time,
with the default date of 0, which translates to 30 Dec 1899. There are
functions for working with Dates, two of which may be particularly pertinent
to your project: DateAdd (even if you are subtracting) and DateDiff.

Larry Linson
Microsoft Access MVP
 
HI Bobby,

As others have mentioned you will have a problem when the call goes over
midnight, I would suggest formatting the Dispatch and scene times as general
dates, thus YYYY MM DD HH.NN, would be entered, then use the following date
Diff as the control source for the calculated time field...

Even if you cant, this will work for you as is providing you dont go over
midnight,...

=DateDiff("n",[DispatchTime],[OnSceneTime])\60 & ":" & Format(DateDiff("n",
[DispatchTime],[OnSceneTime]) Mod 60,"00")

Hope this may help you.
 
Thank everyone for your help. I have the problem solved. Between the
suggestions I recieved from here and the website www.pacificdb.com.au i
completed my project last night.

Again, I thank you and hope to help someone else one day!

--
bobbykayak


butboris via AccessMonster.com said:
HI Bobby,

As others have mentioned you will have a problem when the call goes over
midnight, I would suggest formatting the Dispatch and scene times as general
dates, thus YYYY MM DD HH.NN, would be entered, then use the following date
Diff as the control source for the calculated time field...

Even if you cant, this will work for you as is providing you dont go over
midnight,...

=DateDiff("n",[DispatchTime],[OnSceneTime])\60 & ":" & Format(DateDiff("n",
[DispatchTime],[OnSceneTime]) Mod 60,"00")

Hope this may help you.

Could someone please send or direct me to someplace where I can get a
function to handle the adding and subtracting of Military time? I am
developing a EMS Response tracking system and in all my years of coding, I
have never had to deal with the Short Time format.

Every function I have written I have eventually broke or found an error. I
am getting close to deadline and this is the only problem I need to solve
conclusively. I am using MS Access 2000/VBA

Thanks for your suggestions!
 
As others have implied, there are (at least) two problems involved in
doing what you are trying to do - using Date/Time variables to contain
and display elapsed time periods. Neither is insuperable.

1) Start time before midnight; end time after midnight. It is
perfectly proper to calculate elapsed time as dtEnd - dtStart, as long
as you check for dtEnd < dtStart and add 1 if you have crossed
midnight. If your "runs" can be longer than 24 hours, even this may
not work, and you will have to store and calculate based on start and
end dates and times.

2) The short time format ignores days. If you correctly calculate the
man-time for a given "run" and it exceeds 1 day, displaying it in
short time format will truncate the days. There is, unfortunately, no
built-in date format which will display a period of more than 24 hours
sensibly (eg. "2:07:30" or "55:30"). What you have to do is extract
the days part manually and format your own output however you want it.

Your right, I did not explain my problem correctly. What I am doing(trying!)
is get the correct time intervals(hours,minutes) between the time the
emergency alarm is recieved by the station, time it takes to leave, time it
takes to arrive at the scene, time at the scene, and the time of arrival back
at the station.

Then I need to calculate the total manpower hours(totaltime * number of
men). I have to use Short time format(20:40) for my input boxes. I have tried
to convert and manipulate the data but still seem to come up short of right
when I report the totals.

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Back
Top