Home All Groups Group Topic Archive Search About

How to Calculate hours between st. Date St.Time and End Date EndTi

Author
5 Jul 2005 5:01 AM
prabhu
Hi all,
       In one of my form i need to show the total hours:Mins involved for a
process by getting the user input as st. Date St.Time and End Date EndTime. I
used 4 dtpicker for these and i tried with many conditions but i couldnt get
it. I strongly believe that there should be some simple method to achieve
this, Pls help me to come out of this problem.

Thanks in advance...
Prabhu.

Author
5 Jul 2005 5:31 AM
Rick Rothstein
>        In one of my form i need to show the total hours:Mins involved for a
> process by getting the user input as st. Date St.Time and End Date EndTime. I
> used 4 dtpicker for these and i tried with many conditions but i couldnt get
> it. I strongly believe that there should be some simple method to achieve
> this, Pls help me to come out of this problem.

Give this procedure a try...

StartDateTime = StartDate + StartTime
EndDateTime = EndDate + EndTime
DeltaTotal = DateDiff("n", StartDateTime, EndDateTime) / 1440
DeltaHours = Int(DeltaTotal)
DeltaMinutes = DeltaTotal - DeltaHours
DeltaHoursMinutes = CStr(DeltaHours) & ":" & _
                               Format$(60 * DeltaMinutes, "#")

Rick - MVP