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

Time Diff for Start and End time

Status
Not open for further replies.

gusc999

Technical User
Joined
Nov 20, 2007
Messages
42
Location
US
I am trying to get the time diff from two fields I converted the into time formats but when I try to diff(n,,) or {field1}-{field2} the time difference it does not give me the proper calculation
can someone help me??? I'd greatly appreciate it.

example:

startime: endtime: difftime:
715pm 745pm 00:30:00


Here is the sql statment (SELECT "LDRHHDR3"."LHHRTE", "LDRHHDR3"."LHHSTD", "LDRHHDR3"."LHHSTT", "LDRHHDR3"."LHHENT", "LDRHHDR3"."LHHCLT"
FROM "S650832F"."PIRF"."LDRHHDR3" "LDRHHDR3"
WHERE ("LDRHHDR3"."LHHSTD">=20080902 AND "LDRHHDR3"."LHHSTD"<=20080903) AND "LDRHHDR3"."LHHRTE" LIKE '3%')
===============
Here is the formula to the field I converted to time:

//Field name LDR-STX
WhilePrintingRecords;
Local NumberVar ConvertTime := {LDRHHDR3.LHHSTT};
Local NumberVar MyHours;
Local NumberVar MyMinutes;
Local NumberVar MySeconds;
MyHours := ConvertTime \ 10000;
ConvertTime := ConvertTime mod 10000;
MyMinutes := ConvertTime \ 100;
MySeconds := ConvertTime mod 100;
Time(MyHours,MyMinutes,MySeconds)

===========================================
//Field name LDR-CLT
WhilePrintingRecords;
Local NumberVar ConvertTime := {LDRHHDR3.LHHCLT};
Local NumberVar MyHours;
Local NumberVar MyMinutes;
Local NumberVar MySeconds;
MyHours := ConvertTime \ 10000;
ConvertTime := ConvertTime mod 10000;
MyMinutes := ConvertTime \ 100;
MySeconds := ConvertTime mod 100;
Time(MyHours,MyMinutes,MySeconds)
==================================================

THANK YOU


 
First take your time field to a datetime field. Then perform a datediff. Since your field does not already contain a date, add a constant.

Here are samples I created to test

//Formula 1 (DateTime1)
//Converting time1 to datetime (your start time)
CDateTime(CDate ("January 1, 2008"), {@Time1})

//Formula 2 (DateTime2)
//Converting time2 to datetime (your end time)
CDateTime(CDate ("January 1, 2008"), {@Time2})

//DateDiff forumula:
DateDiff("n",{@DateTime1},{@DateTime2})

Does this make sense? Will it work for you?

-- Jason
"It's Just Ones and Zeros
 
It makes sense but it not working I tried it on two seperate reports and I get the same error message...
"The remaining text does not appear to be part of the formula"


//Formula 1 (DateTime1)
//Converting time1 to datetime (your start time)
CDateTime(CDate ("January 1, 2008"), {@LDR-STX})

//Formula 2 (DateTime2)
//Converting time2 to datetime (your end time)
CDateTime(CDate ("January 1, 2008"), {@LDR-CLT})

//DateDiff forumula:
DateDiff("n",{@LDR-CLT},{@LDR-STX})
 
Jdemmi,

Thanks for you help it worked... greatly appreciated!!!
 
Great!!

-- Jason
"It's Just Ones and Zeros
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top