Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.
Free Trial

Alteryx Designer Desktop Discussions

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

Converting Military Time Integer DataType to Time Datatype and then Add/Substract 45 mins

xaabz
7 - Meteor

I have a time field in the integer datatype in HHMM. I want to convert into Time format HH: MM and then I need to add and subtract 45 min from 2 different columns. Can someone help me with that?


So I want to subtract 45 mins from 15:40 pm so my new time should be 14:55 pm similarly, I need to add 45 minutes in 2035 so my new time should be 2120 pm

zuhaibaliraja_0-1682948438874.png

 

 

18 REPLIES 18
cjaneczko
13 - Pulsar

Update the 30 to 45 and -45.

 

DateTimeFormat(DateTimeAdd("2017-01-01 " +[DateTime_Out],45,"minutes"),'%H%M')

DateTimeFormat(DateTimeAdd("2017-01-01 " +[DateTime_Out],-45,"minutes"),'%H%M')
xaabz
7 - Meteor

This logic worked. However, I can see some null fields when I am trying to convert string to DateTime format. See the attached. How to fix these?

zuhaibaliraja_0-1682953822558.png

 

cjaneczko
13 - Pulsar

Try the Attached. As for the times over 2400, I don't believe military time exceeds 2400. Might have to do a find and replace on any data that starts with 24xx and change it to 00xx. 

 

cjaneczko_0-1682953939646.png

 

binuacs
21 - Polaris

@xaabz updated the workflow

binuacs_0-1682953962497.png

 

cjaneczko
13 - Pulsar

Attached is fixed to accommodate any times 2400 and greater. 

xaabz
7 - Meteor

Thank you so much for the help. It worked but I can see still NULL values in the depart Time column. See below

zuhaibaliraja_0-1682954785918.png

 

cjaneczko
13 - Pulsar

Is the Departure time a String? I had an issue where it picked them up as INT32 and i had to use the selection tool to change it to String for the DateTime tool to work.

xaabz
7 - Meteor

I had to modify it a little bit but it did work. Thank you so much

xaabz
7 - Meteor

It was an integer then I had to change to a string in order to finally update to time. However, someone else answered and solved my issue. Much appreciated!

Labels
Top Solution Authors