Difference of days around DST

My test was suddenly failing to check the number of days between two dates recently.
Looks like SenseTalk calculates the duration of days based on the number of seconds between two dates divided by number of seconds in a day. If two dates are not within the same daylight saving time range, the results can be a decimal number. For example,

put (date("3/11/24") - date("1/11/24")) / 1 day

returns 2.041667 instead of 2. If I compensate the lost hour due to end of DST like this,

put (date("3/11/24") - date("1/11/24") - 1 hour) / 1 day

I get the expected result 2. I can round the number to get what I want, but is there a more elegant way?

@Keiichi_Yamamoto Not sure if it helps. Just give a try for your scenario.

put  dayOfCommonEra("3/11/24") - dayOfCommonEra("1/11/24")

[DayOfCommonEra]
(Date and Time Values in SenseTalk | EPF Docs)

1 Like

Thanks! This works perfectly for my scenario.

Using dayOfCommonEra is a great solution. Just for reference, here’s another way you might do it:
put (date("3/11/24") - date("1/11/24")) rounded to the nearest day

1 Like