The
EOMONTH
Function
The EOMONTH function was introduced in SQL Server 2012. It accepts an input date and time value
and returns the respective end-of-month date, at midnight, as a DATE data type. The function also
supports an optional second argument indicating how many months to add.
Syntax
EOMONTH(input [, months_to_add])
For example, the following code returns the end of the current month.
SELECT EOMONTH(SYSDATETIME());
The following query returns orders placed on the last day of the month.
SELECT orderid, orderdate, custid, empid
FROM Sales.Orders
WHERE orderdate = EOMONTH(orderdate);
www.it-ebooks.info
88
Microsoft SQL Server 2012 T-SQL Fundamentals
Do'stlaringiz bilan baham: |