→ 🚀What's New? Explore Lansweeper's Fall 2024 Updates! Fall Launch Blog !
08-02-2024 12:01 AM
I copied an existing built in report (Helpdesk: Tickets created this month) that I need to sho instead tickets for the previous month every month. Today (e.g. last month), I used the line: Where htblticket.date >= '2024-07-01' And htblticket.date < '2024-08-01'
But I want to schedule the report to run on the 1st of each month, and need the query to always search the previous month, regardless of how many days in that month (28, 29, 30, or 31). Is there a fairly easy way to do this? I litterally have no SQL experiance, so please...detailed explenations.
Alternativley, I can schedule the existing report to run at the end of the month, but i don't know how to, in Lansweeper, to schedule it for the last day of the month as opposed to scheduling it specifically on the date (28th, 29th ,30th, 31st). If that is possble and could be explained it'd probably be a whole lot easier.
08-05-2024 04:40 PM
Dear,
There a few ways in SQL to return data from a previous month. You can start with the getdate() function and extract a month using a DATEADD() function.
There is an example in the link below. You can use similar statements in a where clause.
How to subtract one month from a date using SQL Server - Stack Overflow
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now