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

elapsed time

Status
Not open for further replies.

dkaf

Technical User
Mar 29, 2005
15
US
I am using version Crystal Reports 14.1.1.1036.

I need to create a formula for elapsed time - days, hours, minutes.
I have an insert time - {X_datetime_insert} and a fulfilled time {datetime_acted}.

For example: part requested 10/14/14 at 11:15 AM, part issued 10/16/14 at 1:00 PM for an elapsed time of 2 days, 1 hour, 45 minutes.

Thanks!!

 

Please test this with a variety of dates:

whileprintingrecords;
numbervar v_elapsed;
numbervar v_days;
numbervar v_hours;
numbervar v_minutes;
stringvar v_daystext;
stringvar v_hourstext;
stringvar v_minutestext;

v_elapsed := datediff("s",{X_datetime_insert},{datetime_acted});

v_days := floor(v_elapsed/86400);
v_hours := floor((v_elapsed - (v_days * 86400)) / 3600);
v_minutes := floor((v_elapsed - (v_days * 86400) - (v_hours * 3600))/60);

if v_days = 1 then v_daystext := " day, " else v_daystext := " days, ";
if v_hours = 1 then v_hourstext := " hour, " else v_hourstext := " hours, ";
if v_days = 1 then v_minutestext := " minute, " else v_minutestext := " minutes. ";

totext(v_days,"#") + v_daystext + totext(v_hours,"#") + v_hourstext + totext(v_minutes,"#") + v_minutestext
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top