Microsoft
Software
Hardware
Network
Question : How can I display previous month's records in January?
Hi Experts,
I'm using the following SQL to retrieve previous month's records:
SELECT * FROM ReportTable WHERE MonthOfReport LIKE '%" & MonthName(month(now)-1) & "%' AND YearOfReport like '2010'
How could I replace
YearOfReport like '2010'
with something that displays this year's records, but in January it dispays the previous year's December records.
I'd like to avoid updating the SQL every new year by typing in the actual year '2011' etc.
My goal is to display always the previous month's records.
Thank you very much.
Related Solutions:
How to request previous month's records in my sql's where clause?
Answer : How can I display previous month's records in January?
SELECT * FROM ReportTable WHERE MonthOfReport LIKE '%" & MonthName(month(now)-1) & "%' AND YearOfReport =
year(DATEADD(month, -1, getdate()))
Random Solutions
Checking for Negative Numbers not Working
Using ADMT to migrate user account across domain.
TSQL- Arithmetic overflow error converting float to data type numeric.
Win 7 - Need to uninstall assembly file manually. Access Denied
VBA to name an Access Table after a Form Control
Mac AD logins
adding user to an existing AD group
System.Threading .NET Framework Version
Check for nulls to stop the error - Nullable object must have a value
How to use an Echo Indigo IOx sound card in Ubuntu 10.04 Linux?