Need to calculate diff between time
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
I want to calculate diff between End time and start time.
What method I am using is replacing char ":" with "." but and the change the data type to number.
Which is giving result for few correctly but in case of 104
Where endtime is 5:15 and start time 2:45 by above method I am getting 2.7 as result.
But actually It should be 2.5 (2 hours 30 min)
How to get this?
Thank you in advance.
Solved! Go to Solution.
- Labels:
- Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey @sgaryali,
One way to do this is convert it to the Alteryx Date Time format, then use a the datetime dif function in minutes then divide by 60 to get the hours:
If your interested in learning more about the datetime functions there is a great cheat sheet Blog here: https://community.alteryx.com/t5/Engine-Works/DateTime-Functions-Cheat-Sheet/ba-p/844353
Any questions or issues please ask
Ira Watt
Technical Consultant
Watt@Bulien.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @sgaryali
Please see if this works for you. I parsed the dates, so Alteryx can understand them as dates, calculated the time difference between then in seconds and them divided the result by 3600 (3600 seconds per hour).
DateTimeDiff(datetimeparse([ENDTIME], '%m/%d/%Y %H:%M'), datetimeparse([STARTTIME], '%m/%d/%Y %H:%M'), 'seconds')/3600
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
