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

Date time formula

henrygeorge
8 - Asteroid
Hi Alteryx team,
Please help me in framing a formula in such a way that all rows are with the previous days date eg if today is 18 Nov it results in 17 Nov.. But however 17 Nov and 16 Nov is a holiday so we just take the 15 Nov as the previous date and show it as a result. ie ignoring the weekends. How can this be done?
3 REPLIES 3
benakesh
12 - Quasar

Hi @henrygeorge ,

This  is the formula  for previous workday ( Mon - Fri)  for  a  field : date .  You replace  'date'  with  current date or any other date in your  data .

For Sunday and Monday previous day is Friday . For all other days it is previous day .

 

if DateTimeFormat(date,'%a') = 'Sun' then DateTimeAdd(date,-2,'days')
elseif DateTimeFormat(date,'%a') = 'Mon' then DateTimeAdd(date,-3,'days')
else DateTimeAdd(date,-1,'days')
endif

 

benakesh_0-1574048078756.png

henrygeorge
8 - Asteroid

@benakesh can you please send your alteryx working file?

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @henrygeorge,

 

I've done it slightly differently, just using one formula:

 

IF DateTimeFormat([Date],'%a') = 'Mon'
THEN DateTimeAdd([Date],-3,'day')
ELSEIF DateTimeFormat([Date],'%a') = 'Sun'
THEN DateTimeAdd([Date],-2,'day')
ELSE DateTimeAdd([Date],-1,'day')
ENDIF

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

Labels