Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to convert YYYYMMDDHHMMSS to a date time format that I can calculate the diff?

Emmm
7 - Meteor

For example, the inputs are 20240703193312 and 20240703203312, I'm trying to reach a result of 01:00:00 meaning one hour difference between the two inputs (20240703203312-20240703193312). 

 

Can someone please help? Thank you so much! 

3 REPLIES 3
apathetichell
19 - Altair

note - your field must a be a string going into datetimeparse - so make sure you convert before or wrap it in tostring()

 

formula tool - 3 formulas

new datetime[datefield1] - repeat for new datetimetime[datefield2]

datetimeparse([field],"%Y%m%d%H%M%S")

 

difference field

datetimediff([datefield1],[datefield2],"hours")

 

to convert this to time you'd use:

 

 

datetimeadd('1970-01-01 00:00:00',tonumber(datetimediff([datefield2],[datefield1],"Hours")),"Hours")

 

 

in a new time field.

 slight modifications to include a date and to have datefield2 first.

Raj
16 - Nebula

@Emmm 
find the workflow attached
mark done if solved.

Emmm
7 - Meteor

Thank you both!! @Raj @apathetichell 

Labels