Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert to week number to date

Author  Topic 

soofihussain
Starting Member

11 Posts

Posted - 2015-04-30 : 03:36:41
I want to convert date to week consider saturday is first day of week and friday is end of week. for input is orderdate and output should be week. example orderdate 11.04.15 to 17.04.15 week should be 16. orderdate 18.04.15 week should change to 17. can you provide the solution for this
Order Date Week
11-Apr-2015 16
12-Apr-2015 16
13-Apr-2015 16
14-Apr-2015 16
15-Apr-2015 16
16-Apr-2015 16
17-Apr-2015 16

Order Date Week
18-Apr-2015 17


ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2015-04-30 : 04:06:56
select datepart(week,dateadd(day,1,'18-Apr-2015'))

Go to Top of Page

soofihussain
Starting Member

11 Posts

Posted - 2015-04-30 : 04:10:48
order date is multiple rows of order date not only one date (18-04-15)
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-04-30 : 08:52:22
quote:
Originally posted by soofihussain

order date is multiple rows of order date not only one date (18-04-15)



what does that mean? AFAIK a date is a date. It cannot be multiple dates.
Go to Top of Page
   

- Advertisement -