Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

upaliwije
Contributor II

Week start day

Hi Friends

 

I have following script in my master calendar to create weeks.

 'Week'&Ceil(Day(TRN_DATE)/7) as  MonthlyWeek,

I note that in the above syntax  week start day is Monday. I want to make the start day as Sunday. Kindly help me to modify the script to suit my requirement.

 

5 Replies
Employee
Employee

Re: Week start day

I think you should use the WeekStart function https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/DateAndTimeFun...

 

Argument Description
date The date to evaluate.
period_no shift is an integer, where the value 0 indicates the week which contains date. Negative values in shift indicate preceding weeks and positive values indicate succeeding weeks.
first_week_day

If you don't specify first_week_day, the value of variable FirstWeekDay will be used as the first day of the week.

If you want to use another day as the first day of the week, set first_week_day to:

  • 0 for Monday
  • 1 for Tuesday
  • 2 for Wednesday
  • 3 for Thursday
  • 4 for Friday
  • 5 for Saturday
  • 6 for Sunday

The integer returned by the function will now use the first day of the week that you set with first_week_day as base (0).

Re: Week start day

What exactly are you trying to get here? Week Numbers with respect to Months?

Jan 1st - Jan 6th - Week1
Jan 7th - Jan 13th - Week2
Jan 14th - Jan 20th - Week3
Jan 21st - Jan 27th - Week4
Jan 28th - Jan 31st - Week5
Feb 1st - Feb 3rd - Week1

and so on...?

upaliwije
Contributor II

Re: Week start day

Yes Sunny, 

That is exactly what I want

upaliwije
Contributor II

Re: Week start day

Hi Sunny,

I have tried with SET FirstWeekDay=0;           but it does  not work. Kindly advise me.

 

upaliwije
Contributor II

Re: Week start day

Could u pls share a sample