Alert: There is a planned Community maintenance outage October 16th from approximately 10 - 11 PM PST. During this time the Alteryx Community will be inaccessible. Thank you for your understanding!

Alteryx Designer Desktop Discussions

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

Weak Number and Year for Date

Mancunian
8 - Asteroid

Hello I would like the following by week Number and Year. E.g. 06/02/2018

Week Number: 6  Year : 2018

3 REPLIES 3
cpituley
8 - Asteroid

Hi @Mancunian

 

Please ignore my method below. The link that @danilang provided is a better solution. 

 

To calculate the year you can use the formula: datetimeyear([your date])

 

To get weeks you can use: floor(tonumber(DateTimeDiff ("Jan 1, 2018", [your date in 2018],'days'))/7)

 

If your date is not in 2018 or may change with every date create a new date time column that pulls the year from your date time column and makes it January 1 of that year.

 

Hope this helps. Sorry I don't have access to my Alteryx right now to build a workflow. 

 

Kind regards,

Cameron

danilang
19 - Altair
19 - Altair
neilgallen
12 - Quasar

@Mancunian for starters, you would need to get your date in a standard format (ie. 2018-06-02).

 

That can be done via datetimefparse([date],"%m/%d/%Y"). This will put the date in a format alteryx will work with.

 

As far as year and week number, once you have the correct format above, it's two simple fomulas.

 

datetimeyear([date]) will return your year. 

 

datetimeformat([date],"%U") or datetimeformat([date],"%W") will return the week number, depending on if you want your week to start on Sunday or Monday, respectively.

Labels