on 2016 May 26 11:27 AM
Don't know if one of you can help me with this calculation in crystal report.
I have two time fields
Field 1 (type: Number) : 1459
Field 2 (type: Number): 1503
I need a time difference in hours and minutes: 0 hours and 4 minutes
Seems simple but I can't find a formula which would work.
Hi Rameez,
What do the numbers in these two fields means?
Are they seconds or minutes?
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rameez,
Create a formula with this code:
local numbervar x1 := {field1};
local numbervar x2 := {field2};
local numbervar sec := ctime(tonumber(totext(x2,'#')[1 to 2]),tonumber(totext(x2,'#')[3 to 4]),00) -
ctime(tonumber(totext(x1,'#')[1 to 2]),tonumber(totext(x1,'#')[3 to 4]),00);
local NumberVar Hours := Truncate (sec/3600);
local NumberVar Minutes := Truncate (Remainder (sec,3600)/60);
Totext (Hours,0,"") + ' Hours and ' + Totext (Minutes,0,"") + ' Minutes';
-Abhilash
If you have a DateTime Field, you can try:
datetimevar x1 := {datetime_field1};
datetimevar x2 := {datetime_field2};
numbervar sec := DateDiff('s', x1, x2);
NumberVar Days := Truncate (sec / 86400);
NumberVar Hours := Truncate (Remainder (sec, 86400) / 3600);
NumberVar Minutes := Truncate (Remainder (sec, 3600) / 60);
NumberVar Seconds := Remainder (sec, 60);
(If Days > 1 then Totext(Days,0,'') & " Days " else if Days = 1 then Totext(Days,0,'') & " Day " else "")&
(If Hours > 1 then Totext(Hours,0,'') & " Hours " else if Hours = 1 then Totext(Hours,0,'') & " Hour " else "")&
(If Minutes IN [0.1 to 1] OR Minutes > 1 then Totext(Minutes,0,'') & " Minutes " else if Minutes = 1 then Totext(Minutes,0,'') & " Minute " else "");
-Abhilash
Hi,
numbervar x:=ctime(_Time1)-ctime(_Time2);
numbervar _hmode := x mod 3600;
cstr(x\3600,0) +' Hrs '+ cstr(_hmode\60,0)+' Min' ;
Regards..
Arun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.