Alteryx Designer Desktop Discussions

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

Days til next birthday

pvara
8 - Asteroid

I have a date and I want to calculate #Days to next birthday.

DOB=10/23/2001

 

What would be the formula expression I would use?

 

Thank you

3 REPLIES 3
brindhan
9 - Comet

Hi @pvara

You will need to use the datetimediff function in a formula.

Here's some documentation to give you your solution

https://help.alteryx.com/9.5/Reference/DateTimeFunctions.htm

 

Cheers,

B

pvara
8 - Asteroid

I tried

datetimediff(datetimenow(),[DOB],"Days")

But I am not getting the expected result.

Given the date, I am expecting 364 days for next birthday

MarqueeCrew
20 - Arcturus
20 - Arcturus

@pvara,

 

How did you know my birthday?

 

IF 
DateTimeDiff(Left(DateTimeStart(),4)+"-"+Right(DateTimeParse([DOB],"%m/%d/%Y") ,5),DateTimeStart(),"Days") > 0
THEN
DateTimeDiff(Left(DateTimeStart(),4)+"-"+Right(DateTimeParse([DOB],"%m/%d/%Y") ,5),DateTimeStart(),"Days")
else
DateTimeDiff(Left(DateTimeAdd(DateTimeStart(),1,"Year"),4)+"-"+Right(DateTimeParse([DOB],"%m/%d/%Y") ,5),DateTimeStart(),"Days")
ENDIF

If the difference of today and my birth month & day (using this calendar year) is not a negative number of days, then those days are the answer.  Otherwise count the days until my birth month & day (using next calendar year).  Note:  I edited the formula to use DateTimeAdd().  Without the add of 1 year this way, the formula would fail on leap days.

 

Cheers,

 

Mark

 

P.S.  Since you asked for a formula, I nested all of the date calculations so that they would fit into a single formula.

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels