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

Calculating Date Diff for timestamps in same field 1

Status
Not open for further replies.

Kim296

MIS
Aug 24, 2012
98
0
0
US
Hi Everyone,

How do I calculate the time difference between two date/time timestamps that are in the same field, but use different codes. The fields are linked by the same event number.

For example: EMS arrived at the hospital (incilog.transcode= "H") at 02/28/2017 15:00 (incilog.timestamp (DateTime)) and cleared the hospital (incilog.transcode= "C") at 02/28/2017 15:25 (incilog.timestamp (DateTime)). EMS were on scene at the hospital for 25 minutes.

I can't figure out how to find the date difference between the two dates because they utilize the same table.field with different codes.

Any help is greatly appreciated.

Thanks,
Kim
 
If sorting by event number then by date and doing a datediff using previous or next will not work, then I would try adding the table a second time and joining the table on the event number field.
It would still require some formula logic to be written but seems quite possible.
 
Group by patient and add two formula to capture value for transcode H and C

eg
@arrival
If Trancode = H then timestamp else datetime (1900, 1, 1, 0, 0, 0)

Repeat for Clearing

in Patient footer

ad date diff formula based on max values of two formula

Eg
@Intime

datediff("n", Max(@arrival, patientgroupfield), Max(@Clear, patientgroupfield)

This should return difference in minutes

Ian
 
Thank you Ian,
Your solution worked perfectly. I appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top