We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Leap Year

novice1
8 - Asteroid

Hi all,

 

I have the Period Start and Period End Date as I need to extract data for whole year up to and including yesterday and compare this to the same period last year.

I am using following formula to work out date today last year

 

DateTimeAdd(DateTimeToday(), -364, "days")

 

this is taking into consideration that this year is leap year. Therefore if today is Friday 11/12/2020 - same Friday last year was 13/12/2019

 

Everything is working as intended, except i can see issue occurring when i will need to calculate the same for non-non leap year. 

Is there a way to design this flexibly, even for longer time periods?

Please see my formulas as they are at the moment down below:

 

 

12 REPLIES 12
novice1
8 - Asteroid

@Qiu 

 

thank you.

 

can you share a solved workflow please?

Now I am getting Type mismatch error.

 

I find date formulas quite tricky thing to get my head around. 

Your help in resolving this is much appreciated.

Tyro_abc
11 - Bolide

I modified your formula slightly and it seems to be working, there were some issues with the data type. Please find the workflow attached.

 

The real definition of Leap Year:

     The number should be divisible by 4 and Not divisible by 100. The second condition is required when the year is 1700 or 1900. That is why I used an OR condition to include those years which end with '00'. In that case, the number should be divisible by 400. 

 

The practical definition of Leap Year: 

     We can only check if the number is divisible by 4, other scenario won't come anywhere between 2010 and 2099 ( more than our lifetime 🙂

 

 

** If you are using one formula inside another formula, then the first one needs to defined before/above the dependent formula**

novice1
8 - Asteroid

Thank you.

I was able to modify my original query and it works now. 🙂

Changed year into Date Type Int32 🙂

Labels
Top Solution Authors