Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Create date from year and week

UnknownUser
7 - Meteor

Hi,

 

is it possible to create a date from only year and week information? 

 

I.e. 12th week in 1998 and then pick the date of the first day of the week? 

 

Regards

4 REPLIES 4
JoBen
11 - Bolide

Hi @UnknownUser, here is a formula that might work for you. This is assuming that the first week of the year is numbered 0. I borrowed from an earlier post by @jgo, which is below. Using my formula, you should be able to plug in your own fields for [Week] and [Year].

 

DateTimeAdd(DateTimeAdd(DateTimeParse(ToString([Year]), "%Y"),[Week]*7,"days"),-ToNumber(DateTimeFormat(DateTimeAdd(DateTimeParse(ToString([Year]), "%Y"),[Week]*7,"days"),'%w')),'days')

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Week-Start-formula/td-p/44338 

DavidP
17 - Castor
17 - Castor

I'd create a startofyear date and then use datetimeadd to add 7*weeknumber in days. You can then retrieve the resultant day of week and build some logic to subtract days to get you to the start of the week.

 

You'll have to decide what to do if the start of year falls on a Sat or Sun.

 

date from week.png

CharlieS
17 - Castor
17 - Castor

I've attached an example of @DavidP's suggestion.

maryas
8 - Asteroid

Hello Charlie,

I think you should add -7 for Sunday instead of 0. Then the formula will work fine !

Labels
Top Solution Authors