Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

extract month from date

novice1
8 - Asteroid

hi,

 

i have following formula build into my Alteryx workflow, that always looks at the data for current month and it would pull back data for previous month is today is 1st of the current month. 

 

if DateTimeDay(DateTimeToday()) = 1
then DateTimeAdd(DateTimeAdd(DateTimeToday(),[Date today]*-1,"days"),-1,"month")
else DateTimeAdd(DateTimeToday(),(DateTimeDay(DateTimeToday())-1)*-1,"days") endif

 

I am struggling to modify the above formula to account for the fact that when i run report on Sunday (and if said sunday is in the new month) how can i get data for previous month with the cut off day previous friday?

 

what i am trying to do is to get sales data previous month if sunday is in 2nd November, and look at the current month if sunday is on any other day of the current month

 

15 REPLIES 15
novice1
8 - Asteroid

Hi,

 

Perfect. Thank you. 😊

 

novice1
8 - Asteroid

Hi,

 

just one more question. 

 

I need to apply same logic to last year as i need to compare month on month. 

 

How would I need to modify the formula, please?

 

novice1_0-1604566448814.png

 

Thank you.

messi007
15 - Aurora
15 - Aurora

Hi,

 

It's correct what you have done. The formula below give the same but for last year (year -1)

 

Regards,

novice1
8 - Asteroid

Hi,

I was expecting to see the answer as 2019-10-01 not 2019-11-01

 

Pluss i need to take in consideration the fact that 1st November last year was on Friday. 

 

Please explain the logic behind this calculation

 

thank you

 

 

messi007
15 - Aurora
15 - Aurora

Hello,

 

In this case you will compare the same month between two years.

I added a formula to do that.

messi007_0-1604581890431.png

Attached the workflow,

Regards,

novice1
8 - Asteroid

Thank you. 👍

 

So, when i run this on sunday this week i should get answer as 2020-11-01 and 2019-11-01?

 

Labels
Top Solution Authors