Home > Enterprise >  SQL - All data before current month
SQL - All data before current month

Time:10-05

I would like to retrieve all data before the current month of today. for both

MS SQL Server and MySQL

CodePudding user response:

Got the answer for Microsoft SQL Server

WHERE DATE <  dateadd(month, datediff(month, 0, getdate()), 0)

CodePudding user response:

You could try (adapt the syntax according to the particular SQL product you are using):

WHERE DATE < DATE_TRUNC('month',getdate())
  • Related