PC Review


Reply
Thread Tools Rate Thread

Calculating Elapsed Minutes when changing from PM to AM

 
 
davjoh123@yahoo.com
Guest
Posts: n/a
 
      23rd Jun 2009
Search many posts but not finding the right answer. A lot of posts
suggest the datediff function or subtracting the start time from the
end time and multiply by 24 and 60. This does nothing for the
situation were the time changes from pm to am.

Is there a good answer?



'If IsNull(Me.Duration) Then
If Not IsNull(Me.SetEndTime) And Not IsNull(Me.SetStartTime)
Then

'Hour(Me.SetEndTime - Me.SetStartTime) * 60 +
' Me.Duration = (DateDiff("n", Me.SetStartTime,
Me.SetEndTime))
'stTime = CDbl(Me.SetStartTime)
'endTime = CDbl(Me.SetEndTime)
'dblDuration = Round((endTime - stTime) * 24 * 60, 0)

Me.Duration = Round((Me.SetEndTime - Me.SetStartTime) * 24
* 60, 0)


End If
'End If

 
Reply With Quote
 
 
 
 
Piet Linden
Guest
Posts: n/a
 
      24th Jun 2009
On Jun 23, 5:37*pm, "davjoh...@yahoo.com" <davjoh...@yahoo.com> wrote:
> Search many posts but not finding the right answer. A lot of posts
> suggest the datediff function or subtracting the start time from the
> end time and multiply by 24 and 60. This does nothing for the
> situation were the time changes from pm to am.
>
> Is there a good answer?
>
> *'If IsNull(Me.Duration) Then
> * * * * If Not IsNull(Me.SetEndTime) And Not IsNull(Me.SetStartTime)
> Then
>
> * * * * 'Hour(Me.SetEndTime - Me.SetStartTime) * 60 +
> * * * * * *' Me.Duration = (DateDiff("n", Me.SetStartTime,
> Me.SetEndTime))
> * * * * * * 'stTime = CDbl(Me.SetStartTime)
> * * * * * * 'endTime = CDbl(Me.SetEndTime)
> * * * * * * 'dblDuration = Round((endTime - stTime) * 24 * 60, 0)
>
> * * * * * * Me.Duration = Round((Me.SetEndTime - Me.SetStartTime) * 24
> * 60, 0)
>
> * * * * End If
> * * 'End If


Sounds like a lot of unnecessary work. use DateDiff("n",stTime,
endTime)
Doesn't something like this work for you?
?round(datediff("n",#6/22/2009 8:15 PM#,now)/60,2) & " hrs"
22.43 hrs
 
Reply With Quote
 
davjoh
Guest
Posts: n/a
 
      25th Jun 2009
On Jun 23, 4:41*pm, Piet Linden <pietlin...@hotmail.com> wrote:
> On Jun 23, 5:37*pm, "davjoh...@yahoo.com" <davjoh...@yahoo.com> wrote:
>
>
>
> > Search many posts but not finding the right answer. A lot of posts
> > suggest the datediff function or subtracting the start time from the
> > end time and multiply by 24 and 60. This does nothing for the
> > situation were the time changes from pm to am.

>
> > Is there a good answer?

>
> > *'If IsNull(Me.Duration) Then
> > * * * * If Not IsNull(Me.SetEndTime) And Not IsNull(Me.SetStartTime)
> > Then

>
> > * * * * 'Hour(Me.SetEndTime - Me.SetStartTime) * 60 +
> > * * * * * *' Me.Duration = (DateDiff("n", Me.SetStartTime,
> > Me.SetEndTime))
> > * * * * * * 'stTime = CDbl(Me.SetStartTime)
> > * * * * * * 'endTime = CDbl(Me.SetEndTime)
> > * * * * * * 'dblDuration = Round((endTime - stTime) * 24 * 60, 0)

>
> > * * * * * * Me.Duration = Round((Me.SetEndTime - Me.SetStartTime) * 24
> > * 60, 0)

>
> > * * * * End If
> > * * 'End If

>
> Sounds like a lot of unnecessary work. *use DateDiff("n",stTime,
> endTime)
> Doesn't something like this work for you?
> ?round(datediff("n",#6/22/2009 8:15 PM#,now)/60,2) & " hrs"
> 22.43 hrs


If you go from pm to am the result is incorrect. as an example 11:40
PM to 12:12 AM gives a result of 14?? when it should be 32.
 
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
Re: Calculating total elapsed minutes between two dates T. Valko Microsoft Excel Misc 0 17th Jun 2009 06:48 PM
Calculating total elapsed minutes between two dates Doug in Freight Microsoft Excel Misc 1 17th Jun 2009 06:46 PM
Calculating elapsed minutes from two different date/time entries bubba@bubba.com Microsoft Excel Discussion 3 10th Jan 2009 12:47 PM
Re: Calculating Elapsed Time > Subtract 30 minutes? pietlinden@hotmail.com Microsoft Access Form Coding 0 2nd Dec 2006 12:32 AM
Calculating Elapsed Minutes bonehead Microsoft Access Queries 1 3rd Feb 2004 01:04 AM


Features
 

Advertising
 

Newsgroups
 


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