Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Adding Week_# field

I need to add a column/field showing the weeks in a year where the first week starts on 1/1/2017 and end on 1/5/2017.

Each subsequent week then needs to start on a Friday and end on a Thursday.

Week_1 is 1/1/2017 to 1/5/2017

Week_2 is 1/6/2017 to 1/12/2017

Week_3 is 1/13/2017 to 1/19/2017...........

I also have another date field in the script called "POST DATE".

I am presently using the script below but would like to know if there is a better way to add this field.

LOAD

*,

IF(Match([POST DATE],'1/1/2017','1/2/2017','1/3/2017','1/4/2017','1/5/2017'),'WEEK_1',

IF(Match([POST DATE],'1/6/2017','1/7/2017','1/8/2017','1/9/2017','1/10/2017','1/11/2017','1/12/2017'),'WEEK_2',

IF(Match([POST DATE],'1/13/2017','1/14/2017','1/15/2017','1/16/2017','1/17/2017','1/18/2017','1/19/2017'),'WEEK_3',

'NA'))) AS WEEK# ;

3 Replies
maxgro
MVP
MVP

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

Try

WeekName(date ,0, 4) as Week

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
muthukumar77
Partner - Creator III
Partner - Creator III

Hi,

Change backend script,

SET DayNames='Fri;Sat;Sun;Mon;Tue;Wed;Thu;';

WeekStart(date) & ' to ' & WeekEnd(Date) 

AutoNumber(Year & Month & WeekStart(Date) & WeekEnd(Date)) as WeekNumber

it will return only Week number as 1,2,3,4

Muthukumar Pandiyan