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 |
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2013-01-28 : 05:57:42
|
Hi,If I pass in a quarter-end i.e. 30 sep 2012, then I would like to get the month-end dates of each month in that quarter.So for this example, it should return:31 July 201231 Aug 201230 sep 2012How is this done in sql please?Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-28 : 06:14:22
|
[code]DECLARE @date datetimeSET @date='20120930'SELECT DATEADD(mm,N,DATEADD(qq,DATEDIFF(qq,0,@date),0))-1FROM (SELECT 1 AS NUNION ALLSELECT 2UNION ALLSELECT 3)t [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2013-01-28 : 06:26:54
|
Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-28 : 06:34:00
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|