Wednesday, August 3, 2011

SQL Server Denali: New Function to Get Last Date of Month

 A new function is introduced in SQL Server Denali CTP3, though which you can easily find out last date of any month. Prior to this we were using different methods to get last date of month. Following one, I like most.
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GetDate())+1,0))

But now it’s more easy with EOMONTH() function. Just provide a date in DateTime format or in string format and it will return last date of required month.

Or you can add number months to get last date.

Read More about SQL Server 2012 (Code Name: Denali

·         Introducing New Edition "Business Intelligence"

·         Changing Backup Files Default Path is More Easy Now

·         New Backup/Restore Options

·         CTP 3 Product Guide Released

·         TRY_CONVERT(), a Good Addition

·         Table Partition Limit Enhancement

·         Format(), a Most Wanted Function

·         Get Date/Time from Parts

·         IIFLogical Function

·         A New More Flexible Create Index Dialog box

No comments:

Post a Comment

All suggestions are welcome