kumar25
2 years agoNew Contributor II
Difference between 2 dates
Hi,
I have 2 dates, which are of localdatetime.
Date1 - 2023-08-13T14:17:00.000
Date2 - 2023-08-23T05:00:00.000
I am using the below expression find the difference between them, and i am getting value as 9.6131944444 expecting the value to be 10. Timestamp value to be exclude and dates only have to be compared.
(Date.parse($Date1.toString())-Date.parse($Date2.toString()))/(1000*60*60*24)
kumar25 - This will first strip off the portion of your string that contains the timestamp, then perform the date difference, and finally convert from milliseconds to day.
(Date.parse($Date2.substr(0,10)) - Date.parse($Date1.substr(0,10))) / (1000 * 3600 * 24)
Hope this helps!