Alteryx Designer Desktop Discussions

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

Using datetimeadd() functions on HH:mm:ss format

Rwebber1991
8 - Asteroid

I am having trouble using the DateTimeAdd() function to add minutes to a date field when the data is in HH:mm:ss format, using the function only produces null values. When I use a full datetime format (YYYY-MM-DD HH:mm:ss) I can add minutes no problem. I have included a workflow where both formats are attempted to use the DateTimeAdd() function. Please let me know if you have any suggestions. 

 

Rwebber1991_1-1651870350949.png

 

4 REPLIES 4
CathyS_Slalom
9 - Comet

Hi @Rwebber1991, that's because the DateTimeAdd function can only take date or datetime as input. To work around this, you can mock up a date first and then extract the added time only. 

 

For example:

cathyshi525_0-1651871847775.png

 

rfoster7
9 - Comet

Yeah, if you look at your HH:MI:SS field type in the select tool you'll see that its vstring, not datetime. You can only use datetimeadd on datetime data. When you use the dateparse tool you end up converting it from string to time. You still can't use datetimeadd on time, only on datetime. 

 

I would append a date onto your time, force it into datetime, and then use datetimeadd to add your seconds, then convert back to time.  Something like the attached. 

 

image.png

 

 

Rwebber1991
8 - Asteroid

Okay yeah this is what I was thinking. I wasn't sure if there was a way to add to just the time variable. Thanks.

Rwebber1991
8 - Asteroid

This is helpful thank you.

Labels