Date time today - 1 without weekends?
- 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
Hello guys!
I need to create a column with datetimetoday -1 (one day) and this formula should only consider monday to friday.
The workflow has no historical data, so its reading an SQL for the first time.
An example:
Any tips? Thanks!
Solved! Go to Solution.
- Labels:
- Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @Joker_Hazard I mocked up an approach let me know what you think? For reference the specifiers I used in the datetime functions can be found here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Very Clever solution my friend! Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
If the input dates are all weekdays (Mon-Fri) then you can probably do in one formula step. Basically the structure would be:
IF [INPUT DATE] = Monday THEN
[INPUT DATE] - 3 day
ELSE
[INPUT DATE] -1 day
In alteryx code the only tricky bit is determining whether it is Monday. You can do this with
IF datetimeformat([INPUT DATE],"%w") = 1 THEN
datetimeadd([INPUT DATE],-3,"day")
ELSE datetimeadd([INPUT DATE],-1,"day")
ENDIF
If you have to handle Mondays, Sundays and Saturdays then you would need to say IF Monday then -3, IF Sunday then -2, ELSE -1 day.
nb this avoids using abacus due to problems some people have with that. https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Getting-Day-Of-Week-DOW-in-number-form...
