Click here to Skip to main content
15,064,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get week number for a year start date to some date?
or
how to split dates in weeks like below?

Example
i need like this
C#
1 week 1    01-01-2013 to 01-07-2013
2 week 2    01-08-2013 to 01-16-2013
3 week 3    01-17-2013 to 01-23-2013
4 week 4    01-24-2013 to 01-30-2013
5 week 5    01-31-2013 to 01-06-2013
not like below
C#
1   Week-1  2012-12-30 00:00:00.000    2013-01-05 00:00:00.000
2   Week-2  2013-01-06 00:00:00.000    2013-01-12 00:00:00.000
3   Week-3  2013-01-13 00:00:00.000    2013-01-19 00:00:00.000
4   Week-4  2013-01-20 00:00:00.000    2013-01-26 00:00:00.000
5   Week-5  2013-01-27 00:00:00.000    2013-02-02 00:00:00.000



how to get this dates?
Posted
Updated 20-Oct-13 21:23pm
v2

Use DatePart Function to Get Week Number. Look at following code.
SQL
select (ww,'1-Jan-2013')

Query for getting weeknumber in table
SQL
select Column1,datepart(ww,Column2) from TableName
   
Hi have you looked at the datediff function which should be able to count the number of weeks between 2 dates
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900