Dynamically Declare Start/End Dates From Current Month

Viewed 1360

I have a pretty basic query that I run monthly. Every month I have to manually change the query to fit the current month start and end date. I've tried using some of the examples from previous answers but can't seem the make it work. Notably because I am trying to include the entire last day of the month, as shown by my 23:59:59 parameter. What is the best way to accomplish this?

SELECT *
FROM WorkOrder
where active = 1 and
WorkOrderStatusId in (6,8) AND
dateCreated >= '5/1/2017' and
dateCreated <= '5/31/2017 23:59:59'
2 Answers
Related