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

How the change the negative time to 00:00:00 1

Status
Not open for further replies.

vega83

Programmer
Jun 12, 2008
141
0
0
US
Hi frinds I am doing difference on tow different dattime fields, so in case if the result is in negative i want to show the timevalue as 00:00:00 else the original time. ANy ideas?

Thanks.
V
 
Dear Vega83,

Can you please show your current formula?

Regards,
ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
whileprintingrecords;
numberVar dur := datediff("s",minimum({@Print WMS},{@Date}),minimum({Command.EDI_CRT_TS},{@Date}));
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;
hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

hhmmss := totext(hrs,"00") + ":" + totext(min,"00") + ":" + totext(sec,"00");

hhmmss
 
Dear Vega83;

This will work:
whileprintingrecords;
numberVar dur := datediff("s",minimum({@Print WMS},{@Date}),minimum({Command.EDI_CRT_TS},{@Date}));dur := if dur < 0 then 0 else dur;
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;
hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

hhmmss := totext(hrs,"00") + ":" + totext(min,"00") + ":" + totext(sec,"00");

hhmmss

//formula end

Notice the second assignment of value to the Dur variable.

Regards,
ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
Works like charm, thank you rosemaryl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top