user3115933 user3115933 - 8 months ago 17
SQL Question

T-SQL syntax to filter records where the datetime variable is greater than or equal to the 1st Day of the Current Month

I am using SQL Server 2014 and I need to add a line of code to my SQL query that will filter the data extracted only to those records where the

(a column in database) is
greater than or equal to
1st day of the current month

In other words, the line of code I need is the following:

WHERE StayDate >= '1st Day of Current Month'

is in the
format (eg: 2015-12-18 00:00:00.000)


Use EOMONTH to get the first day of current month

WHERE  StayDate >= Dateadd(dd, 1, Eomonth(Getdate(), -1))