→ 🚀What's New? Explore Lansweeper's Fall 2024 Updates! Fall Launch Blog !

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
CSRose
Engaged Sweeper

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.

1 REPLY 1
FrankSc
Lansweeper Tech Support
Lansweeper Tech Support

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