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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Difference with numbers

Status
Not open for further replies.

BigDaddyE

MIS
Apr 29, 2010
27
US
I have two numerical fields {vst.end_time} and {vst.begin_time} which display military time as numbers. I just want the difference im minutes between the two.

When I have {vst.end_time} = 1325 and {vst.begin_time} = 0905 I want 295 minutes difference not 420.

//When I try the following it errors out because
//{vst_non_vst.begin_time} is numerical not a date;

Local DateTimeVar d1 := {vst_non_vst.begin_time};
Local DateTimeVar d2 := {vst_non_vst.end_time};
DateDiff ("n", d1, d2)
 
1325" or 1325 (which are different values) are NEITHER time values, which would be a NUMERIC value that is a fraction of a DAY.

Parse your mil string into HOUR and MINUTE and put those values into a TimeSerial function to generate the conversion to DAYS, and then proceed to use DateDiff.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
If you convert it to text, this function will turn it to minutes:

Function (Stringvar HHMM)
// ToMinutes Convert HHMM string into minutes for calculations
// Input: HHMM string of time in 24 hour format
// Output: Numeric number of minutes
// Example: ToMinutes(0125) = 85
(val(left(HHMM,2)))*60+val(Right (HHMM,2 )) ;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top