Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

Generating date_key

$
0
0

HI This is my dim_date table

here week_in_year column every 5 days need to change value ,in jan we have 31 days, up to 30 days fine ,for 31 day have contain single week_in_year(i mean 7), but February 1st on words week_in_year will be 8

how it will cme,i am sending my code

SELECT DENSE_RANK() OVER(ORDER BY ((DATEPART(DD,DATE_FLD)-1)/5)+1) AS DENSE_RANK,
DATE_FLD,DATEPART(DD,DATE_FLD) AS DAY_IN_MONTH
,((DATEPART(DD,DATE_FLD)-1)/5)+1 as WEEK_IN_MONTH
,(((DATEPART(DY,DATE_FLD)-1)/5)+1) AS WEEK_IN_YEAR
FROM DIM_DATE
WHERE DATE_FLD>= '2012-01-01' and DATE_FLD<='2012-12-31'
ORDER BY DATE_KEY

plz help me out

Regards

Arjun



Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>