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.
Author |
Topic |
jittu
Starting Member
1 Post |
Posted - 2015-02-16 : 00:25:45
|
Hi,I need to incorporate 2 date logic's in my stored procedure.E.g1st logic(7days logic)1.when i select any date say for instance 16/02/2015 it should give me 7 days including weekend's i.e Saturday and Sunday.The result should be 23/02/20152nd logic(2 business days logic and it should include Saturdays and skip Sunday)2.When i select any date say for instance 16/02/2015 it should give me 18/02/2015 and if i select Friday's date 13/02/2015 it should take Saturday and Monday but not Sunday.So, the result should be 16/02/2015As i am new to SQL server need your help to fix it guys and all your logic's will be appreciated .. |
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2015-02-16 : 00:41:18
|
[code]declare @table table(col1 datetime)insert into @table select '20150216' union all select'20150217' union all select'20150218' union all select'20150219' union all select'20150220' union all select'20150221' union all select'20150222' union all select'20150223' union all select'20150224'select *, DATEPART(weekday, col1) from @tablewhere col1 <= DATEADD(DAY, DATEDIFF(DAY, -7, GETDATE()), 0)select *, DATEPART(weekday, col1)from @tablewhere col1 <= DATEADD(DAY, DATEDIFF(DAY, -7, GETDATE()), 0)and cast(col1 as int)%7 <> 6[/code] |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|