Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to enter current week as two digits in a string

Hello,

I have a script where I need to enter the current year and week as fields. The problem is that I need to enter the current week as two digits (08, 09, 10, 11 etc), but now it enters the week as 8, 9, 10, 11 so the end result for this week is 20181 and not 201801.

Is there any way to set the week standard value as XX and not X?

My script now:

vWeek=Year(now())&week((now()))

AUTOSTOCK:

LOAD

DEAL AS [DEALER],

PRIS AS PRICE,

$(vWeek) AS Week;

SQL SELECT *


FROM ......

Thank you

6 Replies
tresesco
MVP
MVP

Try like:

vWeek=Year(now())& Num( week((now())), '00')

mdmukramali
Specialist III
Specialist III

Hi,

vWeek=Year(now())&Num(week((now())),'00')


or


vWeek=Year(now())&Num(week(now()),'00')

Anonymous
Not applicable
Author

Thank you for the quick response. It worked like a charm!

Do you also know if it is possible to write it as last week so it shows 201752? That is current week minus 1 week.

tresesco
MVP
MVP

This?

vWeek=Year(now())& Num( week((Today()-7)), '00')

tresesco
MVP
MVP

A better solution could be: =Purgechar(Weekname(today(),-1),'/')

Capture.JPG

Anonymous
Not applicable
Author

Beautiful! Works like a charm.

Thank you very much!