How to add or subtract minutes from a 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
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:
Solved! Go to Solution.
- Labels:
- Date Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
datetimeadd([my date],30,"minutes")
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I changed EndTime from String to Time in the select tool, and the workflow ran just fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@MarqueeCrew and @adm510 ... Thanks for the fast response!
I made those two changes but I'm still not getting it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How strange... I am still getting the same error, even with the sample workflow you sent back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Deborah,
Please try this formula:
DateTimeAdd("2017-01-01 " +[Start Time],30,"minutes")
your time needs a date too.
Cheers,
Mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Problem Solved! Thanks, Mark!
