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.
|