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 add or subtract minutes from a time?

ddiesel
13 - Pulsar
13 - Pulsar

How to I add or subtract minutes from a time field? 

 

In this case, I need to add 30 minutes to each of my "Start Times" to get the "End Times".

 

DateTimeAdd([Start Time],+30,"minutes") gives conversion error: DATETIMEADD: "04:00:00" is not a valid DateTime.

 

I can think of a couple workarounds but is there an easy way to do this?

 

Sample workflow:

 

14 REPLIES 14
MarqueeCrew
20 - Arcturus
20 - Arcturus

datetimeadd([my date],30,"minutes")

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
adm510
11 - Bolide

I changed EndTime from String to Time in the select tool, and the workflow ran just fine.

ddiesel
13 - Pulsar
13 - Pulsar

@MarqueeCrew and @adm510 ... Thanks for the fast response!

 

I made those two changes but I'm still not getting it.

adm510
11 - Bolide

Hmm, the workflow you attached ran just fine for me.  What if you remove the EndTime column and create it from the Formula tool instead? (see attached)

ddiesel
13 - Pulsar
13 - Pulsar

How strange... I am still getting the same error, even with the sample workflow you sent back.

 

Capture.PNG

 

adm510
11 - Bolide

Bizarre, I'm using v11.0 so there could potentially be some differences there.  From your screenshot, it doesn't seem like the addition is the problem, Alteryx is having a problem reading your start time as a time and this is why the datetimeadd fails. You may need to add the select tool back and explicitly cast start time as time... but it's still strange that it works without issue for me.

KevinP
Alteryx Alumni (Retired)

This conversion error is occurring because the DateTimeAdd() function is expecting a DateTime value instead of just the Time value being supplied. You can easily correct this in the sample workflow with the follow formula adjustment.

 

DateTimeAdd("1970-01-01 "+[Start Time],30,"minutes")
MarqueeCrew
20 - Arcturus
20 - Arcturus

Deborah,

 

Please try this formula:

 

DateTimeAdd("2017-01-01 " +[Start Time],30,"minutes")

your time needs a date too.

 

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
ddiesel
13 - Pulsar
13 - Pulsar

Problem Solved! Thanks, Mark!

Labels