# Groupe des Utilisateurs Francophones

Vous êtes francophone? Ce groupe est pour vous. Venez découvrir comment démarrer avec Qlik Sense et QlikView, poser vos questions et partager vos tutos et astuces avec les membres de notre communauté.

Highlighted
Esteemed Contributor III

## Creation of a weeknumber based on the existing columns

Hi All,

Can anyone help with the code to achieve the WEEK_NUMBER like 201601,201602,201603,....201652. Based on either Date or Week

column.

Example data for the Date and Week columns are

1 Solution

Accepted Solutions
Partner

## Re: Creation of a weeknumber based on the existing columns

Hi,

this should it be. I used a preceding load before the inline-load.

KR Thomas

Table:

*,

Year(Date#(Mid(Date,7), 'YYYY-MM-DD')) & Num(Week(Date#(Mid(Date,7), 'YYYY-MM-DD')), '00') AS Date_Week,

Year(Date#(Mid(Week,4), 'MM-DD-YYYY')) & Num(Week(Date#(Mid(Week,4), 'MM-DD-YYYY')), '00') AS Week_Week;

Date, Week

SAT - 2015-06-27, Wk 06-22-2015

FRI - 2015-11-06, Wk 11-02-2015

SUN - 2015-06-21, Wk 06-15-2015

SUN - 2015-09-20, Wk 09-14-2015

FRI - 2015-12-18, Wk 12-14-2015

FRI - 2015-12-18, Wk 12-14-2015

WED - 2016-03-02, Wk 02-29-2016

SUN - 2015-06-21, Wk 06-15-2015

TUE - 2016-03-01, Wk 02-29-2016

FRI - 2015-11-06, Wk 11-02-2015

TUE - 2015-08-11, Wk 08-10-2015

SUN - 2015-09-20, Wk 09-14-2015

FRI - 2015-11-06, Wk 11-02-2015

];

3 Replies
MVP

## Re: Creation of a weeknumber based on the existing columns

What is the weeknumber for the same data you have provided? I guess what would be the output for the given data?

Partner

## Re: Creation of a weeknumber based on the existing columns

Hi,

this should it be. I used a preceding load before the inline-load.

KR Thomas

Table:

*,

Year(Date#(Mid(Date,7), 'YYYY-MM-DD')) & Num(Week(Date#(Mid(Date,7), 'YYYY-MM-DD')), '00') AS Date_Week,

Year(Date#(Mid(Week,4), 'MM-DD-YYYY')) & Num(Week(Date#(Mid(Week,4), 'MM-DD-YYYY')), '00') AS Week_Week;

Date, Week

SAT - 2015-06-27, Wk 06-22-2015

FRI - 2015-11-06, Wk 11-02-2015

SUN - 2015-06-21, Wk 06-15-2015

SUN - 2015-09-20, Wk 09-14-2015

FRI - 2015-12-18, Wk 12-14-2015

FRI - 2015-12-18, Wk 12-14-2015

WED - 2016-03-02, Wk 02-29-2016

SUN - 2015-06-21, Wk 06-15-2015

TUE - 2016-03-01, Wk 02-29-2016

FRI - 2015-11-06, Wk 11-02-2015

TUE - 2015-08-11, Wk 08-10-2015

SUN - 2015-09-20, Wk 09-14-2015

FRI - 2015-11-06, Wk 11-02-2015

];

Partner

Hi Chanty 4u,