PC Review


Reply
Thread Tools Rate Thread

Dates - Do I need to write my own function?

 
 
LAS
Guest
Posts: n/a
 
      19th Aug 2010
I have start and end times in tables. I want to write a report that shows
the elapsed time in hours and minutes. I've got the elapsed time in minutes
(currently a string, but it seems as if I could use an integer as well). Is
there anything already written that will convert the minutes (using totals,
the minutes could be in the hundreds or thousands), to hours and minutes?

tia
las


 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      20th Aug 2010
On Thu, 19 Aug 2010 18:36:08 -0400, "LAS" <(E-Mail Removed)> wrote:

>I have start and end times in tables. I want to write a report that shows
>the elapsed time in hours and minutes. I've got the elapsed time in minutes
>(currently a string, but it seems as if I could use an integer as well). Is
>there anything already written that will convert the minutes (using totals,
>the minutes could be in the hundreds or thousands), to hours and minutes?
>
>tia
>las
>


Sure:

DateDiff("h", [start time], [end time]) & ":" & Format(DateDiff("n", [start
time], [end time]) \ 60), "00")

--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      21st Aug 2010
I don't think that will return valid data.

Try the following revision of John's expression (all one line) instead.
DateDiff("n", starttime, endtime)\60 & ":" & Format(DateDiff("n", starttime,
endtime) mod 60, "00")

StartTime = #13:50:00#
EndTime = #14:01:00#
?DateDiff("h", starttime, endtime) & ":" & Format(DateDiff("n", starttime,
endtime) mod 60, "00")
returns 1:00

The revised expression returns 0:11

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

John W. Vinson wrote:
> On Thu, 19 Aug 2010 18:36:08 -0400, "LAS" <(E-Mail Removed)> wrote:
>
>> I have start and end times in tables. I want to write a report that shows
>> the elapsed time in hours and minutes. I've got the elapsed time in minutes
>> (currently a string, but it seems as if I could use an integer as well). Is
>> there anything already written that will convert the minutes (using totals,
>> the minutes could be in the hundreds or thousands), to hours and minutes?
>>
>> tia
>> las
>>

>
> Sure:
>
> DateDiff("h", [start time], [end time]) & ":" & Format(DateDiff("n", [start
> time], [end time]) \ 60), "00")
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      22nd Aug 2010
On Sat, 21 Aug 2010 16:07:06 -0400, John Spencer <(E-Mail Removed)>
wrote:

>I don't think that will return valid data.
>
>Try the following revision of John's expression (all one line) instead.
>DateDiff("n", starttime, endtime)\60 & ":" & Format(DateDiff("n", starttime,
>endtime) mod 60, "00")


Thanks, John - had a brainfade there, your expression is of course the correct
one.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
LAS
Guest
Posts: n/a
 
      24th Aug 2010
Thanks for following up here. I was trying to fix it myself, but it was
going slow.

"John Spencer" <(E-Mail Removed)> wrote in message
news:i4pbla$eq3$(E-Mail Removed)...
>I don't think that will return valid data.
>
> Try the following revision of John's expression (all one line) instead.
> DateDiff("n", starttime, endtime)\60 & ":" & Format(DateDiff("n",
> starttime, endtime) mod 60, "00")
>
> StartTime = #13:50:00#
> EndTime = #14:01:00#
> ?DateDiff("h", starttime, endtime) & ":" & Format(DateDiff("n", starttime,
> endtime) mod 60, "00")
> returns 1:00
>
> The revised expression returns 0:11
>
> John Spencer
> Access MVP 2002-2005, 2007-2010
> The Hilltop Institute
> University of Maryland Baltimore County
>
> John W. Vinson wrote:
>> On Thu, 19 Aug 2010 18:36:08 -0400, "LAS" <(E-Mail Removed)> wrote:
>>
>>> I have start and end times in tables. I want to write a report that
>>> shows the elapsed time in hours and minutes. I've got the elapsed time
>>> in minutes (currently a string, but it seems as if I could use an
>>> integer as well). Is there anything already written that will convert
>>> the minutes (using totals, the minutes could be in the hundreds or
>>> thousands), to hours and minutes?
>>>
>>> tia
>>> las

>>
>> Sure:
>>
>> DateDiff("h", [start time], [end time]) & ":" & Format(DateDiff("n",
>> [start
>> time], [end time]) \ 60), "00")
>>



 
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
How do I write an IF function using dates? Stinky Microsoft Excel Worksheet Functions 2 9th Apr 2010 09:07 AM
need a function (UDF) return X if 2 dates fall between 2 other dates Chris Salcedo Microsoft Excel Worksheet Functions 4 2nd Sep 2009 10:49 PM
How do I write an If(And( function using dates as my logical test? mclovin Microsoft Excel Worksheet Functions 4 25th Mar 2009 05:12 PM
how do you write format results of a function within a function? =?Utf-8?B?c2FuZ2Vl?= Microsoft Excel Worksheet Functions 3 14th Jun 2007 12:45 AM
how do I write a vlookup function within an iserror function so t. =?Utf-8?B?SkJMZWVkcw==?= Microsoft Excel Worksheet Functions 2 16th Mar 2005 10:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:53 AM.