Create Date Dimension Script

Who is online?  0 guests and 1 members
Home  »  Blogs  »  DustinRyan  »  Create Date Dimension Script
jerryol likes this.
 
4.78
/5
Avg: 4.78/5: (1 votes)

Comments (2)

vineet_bidn_dubey
I want to set the Monday-1 To Sunday-7 what change i have to do in the above script
4/23/2012
 · 
 
by
DustinRyan
DustinRyan said:
You would use a Case statement anywhere the day number is references. For instance, if you wanted Monday to be 1 and Sunday to be 7, you could use: CASE DATEPART(DW, @DATE) WHEN 1 THEN 7 WHEN 2 THEN 1 WHEN 3 THEN 2 WHEN 4 THEN 3 WHEN 5 THEN 4 WHEN 6 THEN 5 WHEN 7 THEN 6 END as [DayOfWeekNumber]
4/23/2012
 · 
 
by
user670109
user670109 said:
Hi Dustin, Really good overview of an area that I have been getting into also. Thanks. On the question above, probably easier to set the first day of the week to reflect the day that the business see as Day 1, i.e. use SET DATEFIRST in your code to set Monday as Day one. See http://msdn.microsoft.com/en-us/library/ms181598.aspx JK
8/28/2012
 · 
 
by
DustinRyan
DustinRyan said:
Thanks for the tip.
8/28/2012
 · 
 
by
Blogs RSS Feed

DustinRyan's latest blog posts

Blogs RSS Feed

Latest community blog posts