Dears,
i have a date in the column i want to extend the date by add END of the next month.
Example:--
date : 15-02-2018
Expected Result: 31-03-2018 (add days till END of the next month)
date : 15-01-2018
Expected Result: 28-02-2018 (add days till END of the next month)
Not sure what version of SQL Server you're on, but from 2012 you could use EOMONTH with the optional offset
select EOMONTH('20180215',1)
1 Like
This is the best option (any verson)
SELECT DATEADD(mm,0,GETDATE())-DATEPART(dd,GETDATE()) -- AS PRESENT MONTH LAST DATE
SELECT DATEADD(mm,0,GETDATE())-DATEPART(dd,GETDATE())+1 --- AS NEXT MONTH LAST FIRST DATE
SELECT DATEADD(mm,-1,GETDATE())-DATEPART(dd,GETDATE())+1 ---- AS PRESENT MONTH FIRST DATE