How to use compareDate for multiple units

Hello,

I’m using compareDate formula to determine the total time between two date values. In this case, check_in and check_out. Currently, I’m able to calculate the time between the two date values in one unit only.

For example, let’s the following date values:
check_in = October 14, 2024 at 8:00 PM
check_out = October 17, 2024 at 4:00 PM

Using compareDate([check_in], [check_out], "h") provides an output of 68 for 68 hours.
Where compareDate([check_in], [check_out], "d" )+"d" provides an output of 2d for 2 days.

I would like to result to be 2d 20h. How do I accomplish this?

Thanks!

Hi @rice :wave:

Have you tried this?

compareDate("2024-10-14T20:00:00", "2024-10-17T16:00:00", "d") + "d " + (compareDate("2024-10-14T20:00:00", "2024-10-17T16:00:00", "h") - (compareDate("2024-10-14T20:00:00", "2024-10-17T16:00:00", "d") * 24)) + "h"