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
SQL Server Mirroring Witness
Point to Point connection with Cisco 1841 and Cisco 2611
asp.net need help on a parameterize search via a filter expression
Open Source Proxy
Excel Page with Multiple Columns
Ignore errors when importing sql file in mysql
XP Crash SQL Server Data
Coldfusion SQL how can i get the last bit field type with value 1 in the current row
code to update and edit using ajax and also is should update the database
Testing AD Replication