Hi I have a table tab1 which have 2 columns. The values would be like below
SL_NO CAL_DATE
807 2012-03-18
808 2012-03-19
....
1170 2013-03-16
I need to select from this table between the range of sl_no is 807 and 1170. Apart from this, i need to select 2 derived columns for a week_no_of_month and week_no_of_year.
week_no_of_month will be first 7 days fall in week 1, next 7 days in week 2 like 4 weeks in a period. Then again it has to initialise from week no 1 till it reaches 4 for every 7 days.
week_no_of_year will start from 1 and it will keep continue for every 7 days till it reaches 52.
Please help me in this.
I’m not sure what exactly you need. This will answer your question, but I suspect that this is not a question that should have been asked:
You might take a look at week numbering provided by Sql Server.
UPDATE:
WeekOfYear is simply day of year divided by seven. WeekOfMonth is day of year divided by seven and then by four leaving modulus only.