Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Mlan
Contributor
Contributor

Create Date field from year and weeks

Hi, 

I struggle to create a date field and could need your help. 

Right now I don't have any date field but I have a dimension with weeks written in the following way: 1903, 1904, 1905, 1906... Were 19 stands for the year 2019 and 03 the week number. 

How can I change this dimension to a date field ? 

 

Thanks in advance,

Labels (3)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

You can construct a date from year, week and weekday using MakeWeekDate()

 

LOAD
MakeWeekDate(Year, Week, 0) as Date, //0=  monday
*
;
LOAD 
	year(Date#(LEFT(YearWeek,2), 'YY')) as Year,
	RIGHT(YearWeek,2) as Week 
inline [
YearWeek
1903, 
1904, 
1905, 
1906
];

 

View solution in original post

2 Replies
teiswamsler
Partner - Creator III
Partner - Creator III

Hi Mlan

Year and Weeks can be isolated this way, and will work until 2100.

'20'& num(left( dimension , 2 ),'00') as Year

num(right( dimension , 2 ),'00') as Week

How ever above is not a data field but fields with numeric values.

Br.
Teis

Vegar
MVP
MVP

You can construct a date from year, week and weekday using MakeWeekDate()

 

LOAD
MakeWeekDate(Year, Week, 0) as Date, //0=  monday
*
;
LOAD 
	year(Date#(LEFT(YearWeek,2), 'YY')) as Year,
	RIGHT(YearWeek,2) as Week 
inline [
YearWeek
1903, 
1904, 
1905, 
1906
];