Monday 27 January 2014

How to customize the first DayOfWeek in SHR/Sybase IQ?


How to customize the first DayOfWeek in SHR/Sybase IQ?
 
Setting the first day of the week is not technically a setting in SHR. This setting is at the Sybase IQ level, and changes must be made in the database.
 
The Sybase IQ option DATE_FIRST_DAY_OF_WEEK is, by default, 0, making Sunday the default first day of the week. This option could be set to any of the following values, as appropriate:
 
DATE_FIRST_DAY_OF_WEEK
Value
First Day
0
Sunday
1
Monday
2
Tuesday
3
Wednesday
4
Thursday
5
Friday
6
Saturday
 
The following SQL code may be run in dbisql.exe to change this setting on the pmdb database: 
 
set option DATE_FIRST_DAY_OF_WEEK = 1
 
Change option in this way affect only current user, so you must connect to DB as pmdb_admin user.
 
update datetime set
week_boundary=case when (datepart(mi,time_full_date) = 0 and
                         datepart(hh,time_full_date) = 0 and
                         datepart(dw,time_full_date) = 1) then 1
              else 0
              end;
commit
 
We must also recalculate week numbers to shift Sundays and Mondays to properly weeks.
update DATETIME SET TIME_WEEK_NUMBER=datepart(cwk, TIME_FULL_DATE)
commit 
 

No comments:

Post a Comment