Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Two Time Values 1

Status
Not open for further replies.

MontgomeryPete

Instructor
Apr 3, 2004
57
US
This should be simple, but I can't seem to add two time values calculated using the DateDiff function.

We want to calculate elpased driver time to reduce overtime.

FirstRun:Format(DateDiff ("n",DriverStartTime,LunchOut)/1440,"ShortTime")

SecondRun:Format(DateDiff("n",DriverEndTime,LunchIn)/1440,"ShortTime")

TimeWorked:([FirstRun]+[SecondRun])

If [FirstRun] =4:30 and [SecondRun] = 4:30 the value for [TimeWorked] is 4:304:30.

How can you add time values? The DateAdd function won't work for this. I have searched many threads, but can't find one that describes the necessary conversion.

Thanks for your help.

 





Hi

Datediff already does the conversion, so loose the division by 1440
[tt]
FirstRun:DateDiff ("n",DriverStartTime,LunchOut)

SecondRun:DateDiff("n",LunchIn, DriverEndTime)

TimeWorked:([FirstRun]+[SecondRun])
[/tt]
where [FirstRun], [SecondRun] & [TimeWorked] are in units of MINUTES as defined by DateDiff INTERVAL "n"

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 
Skip,
Thanks for the quick help. I ahd forgotten that the conversion is done in DateDiff.

Pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top