Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
RÉSOLU

First day of a week

Cpirino
Astéroïde

Hi, I have a week number like a 35 and I need the first day of this week.

 

 

4 RÉPONSES 4
TylerNa
Boule de feu

You'll need to have the year associated with the week number and then you can utilize one of these solutions.

 

steven-barsalou
Astéroïde

There are some other good leads to a solution above.  It all depends on how you define the first week of the year, but you can calculate a formula to calculate the Monday of the week, order them, then add a record ID.  That will give you a week number.

 

To calculate the Monday of the week, you can use a formula like the one below.  This is SQL, but you should be able to easily convert it into an Alteryx formula.

Cast(calendar_date - ((calendar_date- Cast('1900-01-01' As Date)) Mod 7 ) As Date) As monday_of_week

jwalder
Boule de feu

Presumes current year by using DateTimeNow() but that could be replaced with an date in a column to get the year of it instead. [week] is then the numeric week number. Using these offsets, Sunday is first day.

 

DateTimeAdd(DateTimeAdd(DateTimeTrim(DateTimeNow(),'year'),[week]*7,'days'),switch(DateTimeFormat(DateTimeAdd(DateTimeTrim(DateTimeNow(),'year'),[week]*7,'days'),'%a'),0,'Mon',-1,'Tue',-2,'Wed',-3,'Thu',-4,'Fri',-5,'Sat',-6,'Sun',0),'days')

AlRoBo
Atome

I wanted to get the first day of the week using a single formula instead of a bunch of tools, so I converted this from steven-barsalou's SQL as recommended.

 

I wanted my week to begin with Sunday, so I changed '1900-01-01' to '1899-12-31'. Here is the Alteryx formula:

 

DateTimeAdd([DateTimeNow],Mod(
DateTimeDiff(ToDate('1899-12-31'),[DateTimeNow],'days')
,7),'days')

Sondage
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Étiquettes