First day of the next month

jaramore picture jaramore · Mar 25, 2014 · Viewed 74.3k times · Source

I'm trying get the results where it only displays OrderDates before the LAST day of the CURRENT month. I'm guessing it would be like this...

SELECT OrderDate
FROM Orders
WHERE OrderDate < (code for first day of the next month?)

Answer

t-clausen.dk picture t-clausen.dk · Mar 25, 2014

First day of next month:

sql-server 2012+

DATEADD(d, 1, EOMONTH(current_timestamp))

sql-server 2008 and older:

DATEADD(m, DATEDIFF(m, -1, current_timestamp), 0)