Monday, September 3, 2012

How to get last day of the month ||End Of Month in Sqlserver 2012

In previous SQL versions we don't have any direct option to get the last day of month using current date or custom date.In Sql 2012 come up with some new built function to get End of Month value i.e EOMONTH.In this post i will given how to use this function in T-Sql.

SELECT EOMONTH ( date ) as LDM,First_Name,Addr,Country from Employee 
If we will given an input like '09/03/2012',Then the result will be like this '2012-09-30'

1 comment:

Anonymous said...

What a waste of product development time.

Any programmer of worth would have already written their own function to do this. - take a day off the first of the month following the month of the date provided - simple specification.