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

DatetimeParse how to skip weekend days?

Joker_Hazard
11 - Bolide

Hi all.

I have a formula that sum(adds) +2 days into a basic date column for later use. The problem is, it's summing with weekend days. For example;

3th of June -> Friday.

What should be done:

Formula adds two days desconsidering weekends, in this case the result would be 7th of June.


What is happening:

Formula is giving the result of 5th of June.

DateTimeFormat(DateTimeAdd(DateTimeParse([DATA_MOVIMENTO],"%Y-%m-%d"),+2,"days"),"%Y-%m-%d")

DATA_MOVIMENTO = 3th of June btw as 2022-06-03.

How to avoid that?

Thanks

 

3 REPLIES 3
IraWatt
17 - Castor
17 - Castor

Hey @Joker_Hazard,

Here is one solution to this problem:

IraWatt_0-1654464826678.png

This formula:

IF DateTimeFormat(DateTimeAdd([DATA_MOVIMENTO],1,"days"),"%A") = "Saturday" 
THEN 
DateTimeAdd([DATA_MOVIMENTO],4,"days")
ELSEIF 
DateTimeFormat(DateTimeAdd([DATA_MOVIMENTO],1,"days"),"%A") = "Sunday" 
THEN 
DateTimeAdd([DATA_MOVIMENTO],3,"days")
ELSE
DateTimeAdd([DATA_MOVIMENTO],2,"days")
ENDIF

Checks the next day after the given date if its Saturday then add 4 days if Sunday add 3 else just add 2 days.

 

Any questions or issues please ask :)
HTH!
Ira

IraWatt
17 - Castor
17 - Castor

Not sure if you need the Sunday check if non of your dates are Saturday. If you have no Saturdays should be fine to remove the Sunday check 👍

binuacs
21 - Polaris

@Joker_Hazard One way of ding this

 

binuacs_0-1654465872598.png

 

Labels