SQL Server 2012 – EOMONTH – Find Last Day of Any Month

In SQL Server 2012, seven new datetime functions have been introduced. EOMONTH is one of them.  This is really useful function because many times we need to find the last date of month. Syntax: EOMONTH ( start_date [, month_to_add ] ) Find Last Day of Current Month Example: SELECT EOMONTH (GETDATE()) Last_Date_Month Result: Date ————– 2012-04-30 Find Last Day of Next Month Example: SELECT EOMONTH (GETDATE(),1) Last_Date_Next_Month Result: Date ————– 2012-05-31 Find Last Day of Previous Month Example: SELECT EOMONTH

» Read more

SQL Server 2012 – New DateTime Functions

There are seven new datetime functions are introduced in SQL Server 2012 as motioned below DATEFROMPARTS ( year, month, day) DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds ) DATETIME2FROMPARTS ( year, month, day, hour, minute, seconds, fractions, precision ) DATETIMEOFFSETFROMPARTS ( year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision ) SMALLDATETIMEFROMPARTS ( year, month, day, hour, minute ) TIMEFROMPARTS ( hour, minute, seconds, fractions, precision ) EOMONTH ()

» Read more
1 2