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
F
Let's understand the method to get first day of current month, we can fetch day component from the date (e.g. @mydate) using DATEPART and subtract this day component to get last day of previous month. Add one day to get first day of current month. E.g. @mydate = 10/8/2019, subtract day component (8 days) will give us 9/30/2019. Now add one day in this outcome to get first of the current month - 10/1/2019.
Formula - DATEADD(day,1,DATEADD(day, -DATEPART(day,@mydate), @mydate))
Now First of the next month - Add one month in above formula DATEADD(month,1,(DATEADD(day,1,DATEADD(day, -DATEPART(day,@mydate), @mydate))))