How do I subtract two dates to find the hours between them when the dates are read in this format Dec 01 2021 12:19 PM AEST?
E.g. I would want Dec 02 2021 02:01 AM AEST - Dec 01 2021 12:19 PM AEST
Thank you in advance
Hi @cayladuplooy
There is a workaround for it. Try this
The actual time can have 24hrs we need to treat it as a string to get more hours.
Hope this helps : )
Here is how you can do it. Change the difference unit as required.Workflow:
Helpful reference document : https://help.alteryx.com/20213/designer/datetime-functions
Hi @cayladuplooy ,
you should convert the date time input fields to a datetime data type first using the datetimeparse function:
DateTimeParse([F1], '%b %d %Y %I:%M %p')
In the next step, DateTimeDiff can return the difference in hours:
DateTimeDiff([DateTime1], [DateTime2], 'hours')
(assume, the converted fields are named "DateTime1" and "DateTime2")
Let me know if it works for you.
Best,
Roland
Thank you Roland, and this takes in to account AM and PM too as it includes %p? Is there a way to create the output with hours + minutes +seconds taken to match too? Example 01:40:00
Thank you, this works too 🙂