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-03-04 : 05:20:24
|
Hi,1- I pass the month-end date such as '31 march 2013',2- The stored proc works out the first and lastdate i.e.@FirstDate='01 jan 2013'@LastDate = '31 march 2013' 3- Then my select query does : select myDate from tblDates where myDate between @FirstDate and @LastDate4- It returns many dates ...5- I would like to get back the month-end dates i.e.31 jan 201328 feb 201331 march 20136- How is this done please?Thank you |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-04 : 06:05:33
|
[code]SELECT DISTINCT DATEADD(dd,-1,DATEADD(mm,DATEDIFF(mm,0,myDate),0))from tblDates where myDate >= @FirstDate and myDate < DATEADD(dd,1,@LastDate)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2013-03-04 : 08:56:06
|
Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-04 : 23:42:19
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|