Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Return number of days in a year

cireost
8 - Asteroid

Hi - is there an easy expression to return the number of days in any given year?  So if input is 5/2/2018 - I would like 365 days returned.  Because of leap years, I want to make sure I get 366 days returned if a date falls within a leap year.

 

Thanks!

5 REPLIES 5
Thableaus
17 - Castor
17 - Castor

Hi @cireost 

 

You could use this -

 

YearDays.PNG

 

 

Create the field of Year

DateTimeYear([Date])

 

Calculate the Days of that Year

 

DateTimeDiff([Year]+'-12-31',[Year]+'-01-01', 'days') + 1

 

Cheers,

Thableaus
17 - Castor
17 - Castor

Have no idea why these 12-31 keep showing up.

 

But instead of those, you may need to reference 12-31 and 01-01, end and beginning of the year.

 

Cheers,

danilang
19 - Altair
19 - Altair

@Thableaus 

 

Maybe we have to play "guess the offending word"

 

DateTimeDiff([Year]+'-12-31',[Year]+'-01-01', 'days') + 1

 

Edit:  It worked for me

 

Dan

PhilipMannering
16 - Nebula
16 - Nebula

Here's a fun alternative,

 

wfwf

The below sample is the one I have used for my Workflow logic. Hope this is useful.

Labels