T-SQL reference › EOMONTH
EOMONTH in SQL Server: last day of the month
EOMONTH returns the last day of the month of a date. Finance lives on month ends. First of the month is one day after last month’s EOMONTH.
This month so far
DECLARE @today date = CAST(GETDATE() AS date);
DECLARE @start date = DATEADD(day, 1, EOMONTH(@today, -1));
SELECT order_id, order_date, total_amount
FROM Orders
WHERE order_date >= @start
AND order_date < DATEADD(day, 1, @today);
EOMONTH(@today, -1) is last day of last month. Add a day, you have this month’s 1st.
Try it on Harbour & Co
Amy Nair (Finance Lead) needs this now: “Monthly revenue for the finance pack, shipped orders only. Oldest month first.” Write the query, run it, send the results. On the paid plan.
Take the ticket →Learn it on a real ticket
Monday is free on WorkSQL. A colleague’s ticket lands, you write the T-SQL, we mark it. No videos. Five minutes.
Clock in free See Monday’s tickets