Calculating lapsed time between two dates

I'm trying to calculate the lapsed time (down to hours and minutes) between two dates.

For example, let's say:
Date 1: 7/19/2024 11:24 AM
Date 2: 7/22/2024 11:06 AM

I would like the response to be "2 days, 23 hours, and 42 minutes".

Hi Ryan,

Here's a thread showing how to subtract two dates:

It uses "days" but you could use other time units like hours (use "h" instead of "D") or minutes (use "m" instead of "D").

Great, thanks Scott!

My goal is to calculate the total time difference (in terms of days, hours, and minutes) between date/times?

For example, if my start date was "7/22/24 10:00 AM", and my end time was "7/22/24 11:00 AM", I'd like the output to be "2 days 1 hour 0 minutes"; any suggestions?

Hey Ryan,

You can achieve that with the example from the post Scott posted, and then calculating the differences for days, hours and minutes:

Start Date: {formdate: YYYY-MM-DD HH:mm; name=start}
End Date: {formdate: YYYY-MM-DD HH:mm; name=end}
{minutes=datetimediff(start, end, "m")}
{hours=datetimediff(start, end, "h")}
{days=datetimediff(start, end, "D"); trim=right}
{totalhours= hours - (days * 24)}
{totalminutes=minutes - (((days * 24) + totalhours) * 60)}

Difference is {=days} days, {=totalhours} hours, {=totalminutes} minutes

This is EXACTLY what I needed. Thank you, Obed!! :grin:

1 Like