Hello I would like the following by week Number and Year. E.g. 06/02/2018
Week Number: 6 Year : 2018
Solved! Go to Solution.
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
Mancunian
See this post https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Calculating-the-week-number/td-p/12234. specifically the solution from @Harsha
Dan
@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.