cancel
Showing results for 
Search instead for 
Did you mean: 

Subtracting times in crystal reports

Former Member
0 Kudos

Hi All,

I have a time fields like this email sent time 1:11:00 AM and call time 1:33:32PM.

I need subtract call time from email sent time .I did like this but getting numbers.

email sent time-call time

Please help

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Prasad,

If you need the difference in hh:mm:ss format, use this code:

NumberVar TotalSec := {email sent time} - {call time};
NumberVar Hours := Truncate (Remainder (TotalSec, 86400) / 3600);
NumberVar Minutes := Truncate (Remainder (TotalSec, 3600) / 60);
NumberVar Seconds := Remainder (TotalSec, 60);
(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

Answers (1)

Answers (1)

former_member292966
Active Contributor
0 Kudos

Hi Prasad,

The number you are getting is the seconds between your times. So take that number and divide by 60 and you will get the number of minutes.

Your formula should look like:

({table.email sent} - {table.call time}) / 60; 

This will give you 697.47 minutes.

(({table.email sent} - {table.call time}) / 60) / 60; 
or
(({table.email sent} - {table.call time}) / 3600); 

Will give you 11.62 hours.

Thanks,

Brian