View Single Post
  #5  
Old June 3rd, 2010, 10:40 PM posted to microsoft.public.access.queries
Bob Barrows
external usenet poster
 
Posts: 475
Default Storing time as integers

Why not? All you need to realize is that date/times are stored as
doubles, with the time portion being the decimal portion. So 12 hours
would be stored as .5 and 23:59.9999 seconds would be stored as .999....
To convert a time value to seconds, just multiply it by (24*60*60)


SSi308 wrote:
I understand the gist of it, but the field is currently a Date/Time
field. It is populated by importing call records from another program.

Can I write a query that will convert that field to seconds?

"John Spencer" wrote:


You can do it with some math.

If you store the duration in seconds. And for example the duration
is 7356

There is no field type in Access that stores duration.

One way to handle duration is to use a numeric field and store the
number of units of time that is the smallest that you are interested
in recording. In your case you might be storing the seconds. Then
you can manipulate the seconds to get duration in terms of hours,
minutes and seconds. Assuming that your field is named "Duration"

Seconds: Duration Mod 60
Minutes: (Duration\60) Mod 60
Hours: Duration\3600

To display that as hours minutes and seconds

Duration\3600 & ":" & Format((Duration\60) Mod 60,"00") &
Format(Duration Mod 60,"00")


HTH


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

SSi308 wrote:
I have a call database that includes a field for length of call. I
have created a query that includes employee, date, and length of
call.

I need to calculate the average call length per employee and as a
whole. I found one post that suggested the following:
"To store time intervals you should store them as integers that
represent the number of hours or minutes or seconds, etc.. and then
you can perform whatever math you like. The results can then be
converted to the hh:nn:ss format for display. "

How is this accomplished?

Lori

.


--
HTH,
Bob Barrows