Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
bill_mtc
Partner - Creator
Partner - Creator

How can I fix week number because "Dec 31, 2012" is in week one of year 2012?

We all know that a calendar year has 52 weeks. I wonder why Dec 31, 2012 is in "week one" of year "2012"... Have you notice it? How can I fix this issue?

time.pngscript.png

Regards,

Bill

8 Replies
tresesco
MVP
MVP

This is because by default the first week of year starts on MONDAY of the first week. If you want 1st Jan as the starting of the week then you have to tweak your code, something like:

Ceil((Date(TempDate)-YearStart(TempDate))/7)  as Week

MayilVahanan

Hi

Use Floor

Week(Floor(TempDate))

Hope that helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
rbecher
MVP
MVP

Change the Listbox "Year" to use the field WeekYear (instead of Year) to get UI consistent.

- Ralf

Astrato.io Head of R&D
rbecher
MVP
MVP

..or maybe better use WeekYear (or WeekName(..)) in the Listbox "Week".

Astrato.io Head of R&D
hic
Former Employee
Former Employee

The week numbers in QlikView follow the ISO 8601 definitions. And with these, week one sometimes starts the year before. If you want to define your week numbers differently, you can do this in the script. One example on a script that does this can be found in the following blog post: Ancient Gods and Modern Days

HIC

bill_mtc
Partner - Creator
Partner - Creator
Author

exchange.png

Above table box you can notice that they are interchanged week no.

Jan 1 should be week1, and Dec 31 should be week52

CELAMBARASAN
Partner - Champion
Partner - Champion

You can use LunarWeekName

To get WeekNo you can use

=SubField(LunarWeekName(FieldName), '/', 2)

jagan
Luminary Alumni
Luminary Alumni

Hi,

12/31/2012 falls in Year 2013 first week and

1/1/2012 falls in Year 2011 52nd week.

Try like this, calculate week number manually 

LOAD
Date

(Date + RowNo()) AS Date,
Ceil(DayNumberofYear(Date(Date + RowNo()))/7) AS Week;
LOAD
YearStart(Today(), -1) AS Date
AUTOGENERATE(800);

Hope this helps you.

Regards,

Jagan.