Skip to Content
avatar image
Former Member

Subtracting times in crystal reports

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 28, 2016 at 07:51 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2016 at 06:40 PM

    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

    Add comment
    10|10000 characters needed characters exceeded