PC Review


Reply
Thread Tools Rate Thread

calculating duration/converting hours to days, etc

 
 
=?Utf-8?B?S0dCIGluIFRvcm9udG8=?=
Guest
Posts: n/a
 
      28th Mar 2007
I have a table which collects the time it took for a service call to be
completed. Currently i can only enter up to 23:59 minutes. But however some
service calls takes days to resolve the problem(s). How do I modify this to
include days:hours:minutes? Also this data (field) is summed up at the end of
the report. currently it works out ok giving me eg say 80:25 to mean 80hours
and 20minutes. I would like the hours to be converted to days. Any help will
be greatly appreciated.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?S0dCIGluIFRvcm9udG8=?=
Guest
Posts: n/a
 
      28th Mar 2007
Thank you very much. I'll try it and let you know how it goes.
cheers

"Ken Sheridan" wrote:

> You can't use a date/time data type for this as that represents a point in
> time rather than a duration. It is actually implemented in Access as a 64
> bit floating point number as an offset from 30 December 1899 00:00:00 with
> the integer part representing days and the fractional part the times of day.
>
> You could use a single column of text data type and parse out the days,
> hours and minutes values, but the simplest approach is to use three separate
> columns (fields) for Days, Hours and Minutes. You can give the latter two
> validation rules of <24 and <60 respectively.
>
> To sum the values of the three fields and return a single string value in
> the format days:hours:minutes I'd suggest adding a little function to a
> module in your database:
>
> Public Function DHM(intDays As Integer, intHours As Integer, intMinutes As
> Integer) As String
>
> Dim intMinVal As Integer
> Dim intHourVal As Integer
> Dim intDayVal As Integer
>
> intHourVal = (intMinutes \ 60) + intHours
> intDayVal = (intHourVal \ 24) + intDays
> intHourVal = intHourVal Mod 24
> intMinVal = intMinutes Mod 60
>
>
> DHM = intDayVal & ":" & intHourVal & ":" & intMinVal
>
> End Function
>
> This uses integer division to get the number of days in the total number of
> hours and the number of hours in the total number of minutes, and the Mod
> operator to return the number of hours and minutes left over. You can call
> it as the ControlSource property of a text box in the report footer, passing
> the sum of each column into the function like so:
>
> =DHM(Sum([Days]), Sum([Hours]), Sum([Minutes]))
>
> I'd give some thought to the desirability of representing job times in this
> way, however. Because people by and large don't tend to work 24 hours in a
> day, a day as a unit for payroll or invoicing purposes is in most situations
> not very suitable (there are exceptions: Jim Rockford seemed to go on for
> years charging "200 dollars a day plus expenses", and I used to be paid at a
> daily rate myself in the days when I did a lot of site work). The majority
> of time logging applications I've encountered have worked in hours, however.
>
> Ken Sheridan
> Stafford, England
>
> "KGB in Toronto" wrote:
>
> > I have a table which collects the time it took for a service call to be
> > completed. Currently i can only enter up to 23:59 minutes. But however some
> > service calls takes days to resolve the problem(s). How do I modify this to
> > include days:hours:minutes? Also this data (field) is summed up at the end of
> > the report. currently it works out ok giving me eg say 80:25 to mean 80hours
> > and 20minutes. I would like the hours to be converted to days. Any help will
> > be greatly appreciated.

>

 
Reply With Quote
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      28th Mar 2007
You can't use a date/time data type for this as that represents a point in
time rather than a duration. It is actually implemented in Access as a 64
bit floating point number as an offset from 30 December 1899 00:00:00 with
the integer part representing days and the fractional part the times of day.

You could use a single column of text data type and parse out the days,
hours and minutes values, but the simplest approach is to use three separate
columns (fields) for Days, Hours and Minutes. You can give the latter two
validation rules of <24 and <60 respectively.

To sum the values of the three fields and return a single string value in
the format days:hours:minutes I'd suggest adding a little function to a
module in your database:

Public Function DHM(intDays As Integer, intHours As Integer, intMinutes As
Integer) As String

Dim intMinVal As Integer
Dim intHourVal As Integer
Dim intDayVal As Integer

intHourVal = (intMinutes \ 60) + intHours
intDayVal = (intHourVal \ 24) + intDays
intHourVal = intHourVal Mod 24
intMinVal = intMinutes Mod 60


DHM = intDayVal & ":" & intHourVal & ":" & intMinVal

End Function

This uses integer division to get the number of days in the total number of
hours and the number of hours in the total number of minutes, and the Mod
operator to return the number of hours and minutes left over. You can call
it as the ControlSource property of a text box in the report footer, passing
the sum of each column into the function like so:

=DHM(Sum([Days]), Sum([Hours]), Sum([Minutes]))

I'd give some thought to the desirability of representing job times in this
way, however. Because people by and large don't tend to work 24 hours in a
day, a day as a unit for payroll or invoicing purposes is in most situations
not very suitable (there are exceptions: Jim Rockford seemed to go on for
years charging "200 dollars a day plus expenses", and I used to be paid at a
daily rate myself in the days when I did a lot of site work). The majority
of time logging applications I've encountered have worked in hours, however.

Ken Sheridan
Stafford, England

"KGB in Toronto" wrote:

> I have a table which collects the time it took for a service call to be
> completed. Currently i can only enter up to 23:59 minutes. But however some
> service calls takes days to resolve the problem(s). How do I modify this to
> include days:hours:minutes? Also this data (field) is summed up at the end of
> the report. currently it works out ok giving me eg say 80:25 to mean 80hours
> and 20minutes. I would like the hours to be converted to days. Any help will
> be greatly appreciated.


 
Reply With Quote
 
Jamie Collins
Guest
Posts: n/a
 
      28th Mar 2007
On Mar 28, 1:58 am, Ken Sheridan
<KenSheri...@discussions.microsoft.com> wrote:
> the simplest approach is to use three separate
> columns (fields) for Days, Hours and Minutes. You can give the latter twovalidationrules of <24 and <60 respectively.


If this a scalar value -- and I suggest that it is -- then it should
be in one column. I'd recommend using the smallest time granule
required (i.e. minutes) as the scale.

Jamie.

--


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting total number of hours (>24 hours) into days MV Rao Microsoft Excel Misc 1 24th Jan 2008 12:50 PM
Calculating days and hours Woodturner Microsoft Excel Worksheet Functions 5 11th Dec 2007 05:09 PM
Calculating elapsed days and hours =?Utf-8?B?TGF1cmlT?= Microsoft Excel Misc 4 25th Aug 2006 05:40 AM
Problem converting Hours to Days, Hours, Minutes =?Utf-8?B?Wnl6eng=?= Microsoft Excel Worksheet Functions 4 24th Oct 2005 04:19 PM
converting hours to days,hours,minutes =?Utf-8?B?TF9uX2Rh?= Microsoft Excel Worksheet Functions 2 29th May 2005 06:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:49 AM.