PDA

Click to See Complete Forum and Search --> : REQ help: Calculating elapsed time from date/time began from Date/time ended


Nicholas
Nov 20th, 1999, 06:27 AM
I have four controls, two are Date-Time Pickers set for Date and the last two are text boxes set for Time with the "...If Not IsTime()..." validation.

It is the standard Date and Time problem began, Date and Time problem ended.

I am trying to calculate the elapsed time between these in "" DAYS "" HOURS ""MINUTES.

I coded this in Lotus Notes yet exporting my knowledge to VB is problematic.

Has anyone a code snippet of how to do this in VB - yes, I know about the DateDiff.

Many, MANY thanks!

DiGiTaIErRoR
Nov 20th, 1999, 06:56 AM
well you could divide the date in sections like

hours = left$(time,2)
minutes = mid$(time,3,1)
seconds = right$(time,2)

then just subtract that from the beginning time by doing the same.you'ld probably have to use 24 hour time though or you could possibly use 12 hour time with am and pm just use:

if right$(time$,2) = "PM" then
hourstot = left$(time$,2)
hours = val(hourstot) + 12
else
hours = val(left$(time$,2))
end if

that should work i wrote it without testing so it should work! :) good luck!

------------------
DiGiTaIErRoR

[This message has been edited by DiGiTaIErRoR (edited 11-20-1999).]