Dates are always happy to work in any programming language, SQL is not excluded.
To answer your question, to find all the records that occurred last month
select S.DATEENTERED ,* from sometable S where S.DATEENTERED between dateadd(mm, datediff(mm, 0, dateadd(MM, -1, getdate())), 0) and dateadd(ms, -3, dateadd(mm, datediff(mm, 0, dateadd(MM, -1, getdate())) + 1, 0)) order by 1
To extend the best means of retrieving records over a specific time interval, use the dated file function, the dateadd function, and the condition between conditions in the where clause.
select 'howdy' ,getdate() where getdate() between dateadd(mm, 0, 0) and dateadd(ms, -3, dateadd(mm, datediff(mm, 0, dateadd(mm,-1,getutcdate())) + 1, 0))
The above code will not return records because it checks if today is between 1900-01-01 00: 00: 00.000 and the last possible recorded date of the last month (last day and 23:59: 59.997 - SQL Server DATETIME columns have no more than 3 milliseconds).
The following code will return the record as the date we are looking for, a month ago.
select 'howdy' ,dateadd(mm, -1, getdate()) where dateadd(mm, -1, getdate()) between dateadd(mm, 0, 0) and dateadd(ms, -3, dateadd(mm, datediff(mm, 0, dateadd(mm,-1,getutcdate())) + 1, 0))
Where clause break:
WHERE getdate() -- date to check between dateadd(mm, 0, 0) -- begin date and dateadd(ms, -3, dateadd(mm, datediff(mm, 0, dateadd(mm,-1,getutcdate())) + 1, 0)) -- end date
Finally, many dates can be set this way, here is a pretty complete list:
select dateadd(mm, 0, 0) as BeginningOfTime ,dateadd(dd, datediff(dd, 0, getdate()), 0) as Today ,dateadd(wk, datediff(wk, 0, getdate()), 0) as ThisWeekStart ,dateadd(mm, datediff(mm, 0, getdate()), 0) as ThisMonthStart ,dateadd(qq, datediff(qq, 0, getdate()), 0) as ThisQuarterStart ,dateadd(yy, datediff(yy, 0, getdate()), 0) as ThisYearStart ,dateadd(dd, datediff(dd, 0, getdate()) + 1, 0) as Tomorrow ,dateadd(wk, datediff(wk, 0, getdate()) + 1, 0) as NextWeekStart ,dateadd(mm, datediff(mm, 0, getdate()) + 1, 0) as NextMonthStart ,dateadd(qq, datediff(qq, 0, getdate()) + 1, 0) as NextQuarterStart ,dateadd(yy, datediff(yy, 0, getdate()) + 1, 0) as NextYearStart ,dateadd(ms, -3, dateadd(dd, datediff(dd, 0, getdate()) + 1, 0)) as TodayEnd ,dateadd(ms, -3, dateadd(wk, datediff(wk, 0, getdate()) + 1, 0)) as ThisWeekEnd ,dateadd(ms, -3, dateadd(mm, datediff(mm, 0, getdate()) + 1, 0)) as ThisMonthEnd ,dateadd(ms, -3, dateadd(qq, datediff(qq, 0, getdate()) + 1, 0)) as ThisQuarterEnd ,dateadd(ms, -3, dateadd(yy, datediff(yy, 0, getdate()) + 1, 0)) as ThisYearEnd
Using the list above, you can define a range of any type.