02-09-2024 04:12 AM
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)
02-09-2024 04:18 AM
Hello @kumar25,
You can try with the following expression in a Mapper Snap:
Math.abs((Date.parse(Date.parse($Date1.toString()).toLocaleDateString())-
Date.parse(Date.parse($Date2.toString()).toLocaleDateString()))
/(1000*60*60*24))
Try it, and let me know if this helps you!
Regards,
Aleksandar.
02-09-2024 04:37 AM
@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!
02-11-2024 09:34 PM
Thanks @koryknick