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 |
|
amitranjan
Starting Member
45 Posts |
Posted - 2010-05-17 : 10:58:04
|
| I need the logic below to retrieve end date from a given dateEnddate is the date closest to the 15th or last day of the month which is not greater than the startdateExample If the startdate is between 3/1/10 and 3/15/10 then the enddate would be 3/15/10, if the date is between 3/16/10 and 3/31/10 then the end date is 3/31/10 amit Ranjan |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-17 : 11:16:59
|
| declare @d datetimeset @d=getdate()If day(@d)>15select dateadd(month,datediff(month,0,@d)+1,-1)elseselect dateadd(month,datediff(month,0,@d),14)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|