Forgive me if this is discussed somewhere else, and I just didn't know how to ask the question. My issue is; How to calculate a time interval greater than 24 hours. I have a formula comprised of 2 other formulas that looks like this:
Time({%EMS_Departed_DateTime}) - Time ({%Pt_Arrival_DateTme})
This was created, because we had an issue with Dates and Times being stored as separate values in the database. The SQL expressions look like this:
CAST(
CONVERT(Varchar(10),PT_ArrivedAtED,112)+ ' ' +
CONVERT(Varchar(8),PT_ArrivedAtED_Time) AS DateTime)
What I need is a calculation of a time interval represented as:
HH:mm:ss
I did some research and found this:
WhilePrintingRecords;
NumberVar TotalSec :=({@LengthofStay_Time});
NumberVar Days := Truncate (TotalSec / 86400);
NumberVar Hours := Truncate (Remainder ( TotalSec , 86400) / 3600) ;
NumberVar Minutes := Truncate (Remainder ( TotalSec , 3600) / 60) ;
NumberVar Seconds := Remainder (TotalSec , 60) ;
Totext (Days , '00' ) + ':' +
Totext ( Hours , '00' ) + ':' +
Totext ( Minutes , '00' ) + ':' +
Totext ( Seconds , '00' )
This almost works. What I see after all of this is calculated and converted to display the time as demonstrated above is hours, minutes, and seconds. It will not calculate a number of days (or, preferably a total number of hours (i.e. 2 days = 48 hours), minutes, and seconds. I am looking for advice/solution as to how I should write a formula or SQL expression that would calculate the time interval from {%Pt_Arrival_DateTme}
to {%EMS_Departed_DateTime}
displayed as HH:mm:ss. Thank you in advance for your guidance and advice.