Alteryx Designer Desktop Discussions

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

date today last year

novice1
8 - Asteroid

I am looking out for a solution, to get the below formula to return date for today last year.

 

For example, date today (Sunday) is 2020-11-15, but date on Sunday last year was 2019-11-17.

 

DateTimeAdd(DateTimeToday(),+2,"days") will provide an output of 17/11/2020

 

Is there a way I can get a this date, but in 2019?

5 REPLIES 5
Emil_Kos
17 - Castor
17 - Castor

Hi @novice1,

 

If you will minus 364 days you will get a result that you are interested in.

 

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

MarqueeCrew
20 - Arcturus
20 - Arcturus

Or you can try:

 

ToString(ToNumber(Left([date field],4))-1) +
Substring([date field],4)

 

 cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
RolandSchubert
16 - Nebula
16 - Nebula

Hi @novice1 ,

 

are you looking for the date last year or the same weekday? I think, you need an addition "adjustment", i.e. a difference between weekday this year and weekday last year. I've attached a workflow to calculate using a formula tool "step-by-step".

 

Let me know if it works for you.

 

Best,

 

Roland

novice1
8 - Asteroid

Thank you all for your responses.

 

I have existing formula and used simples of solutions

 

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

 

It is simple and it works, as I already have quite a few formulas running to calculate Year start and year end for 2020 and 2019, Where year end is always last Friday of previous week.

 

Regards,

Egle

Emil_Kos
17 - Castor
17 - Castor

Hi @novice1,

 

Thank you for marking my post as a solution.

Good luck!

Labels