SQL: How to get previous and current month records?

SQL Server – Database Design. How to return the current month first date and the previous month first date between values, but its gives us the different values. You can do like this: f.StartDateKey >= DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0) and f.StartDateKey < DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) Another way is this (if on SQL 2012 and above) f.StartDateKey >= DATEADD(dd,1,EOMONTH(GETDATE(),-2)) and f.StartDateKey …

SQL: How to get previous and current month records? Read More »