Hey Ephraim.
I have thrown together a task which should do what you need. The code is a bit verbose and could be cut down a touch, but hopefully it's human readable enough for you to pick out what its doing.
Effectively, it takes the current date to then grab a date from last month, and then gets the first and last date of that month to then use in the audit method.
Class Demo.Tasks.MonthlyAudit Extends %SYS.Task.Definition
{
Method OnTask() As %Status
{
Set tSC = $$$OK
//Get Current Date
Set CurentDatetime = $ZDATETIME($HOROLOG,3)
//The report needs to be for last month, so get a date from last month based on todays date
Set LastMonth = $SYSTEM.SQL.DATEADD("MM",-1,CurentDatetime)
//Get last Day of last month As Horolog
Set LastDayHoro = $SYSTEM.SQL.LASTDAY(LastMonth)
//Convert Horolog into a Date
Set LastMonthEnd = $ZDATETIME(LastDayHoro,3)
//Get First Day of Last Month
Set LastMonthStart = $SYSTEM.SQL.DATEPART("YYYY",LastMonthEnd)_"-"_$SYSTEM.SQL.DATEPART("MM",LastMonthEnd)_"-01"
//Switch to the %SYS Namespace
ZNspace "%SYS"
Set tSC = ##class(%SYS.Audit).Export("AuditExport.xml",,,LastMonthStart_" 00:00:00",LastMonthEnd_" 23:59:59")
Quit tSC
}
}Then, when setting the task up, I would set it to run on the first Monday of the Month, and it will grab everything from the previous month.
- Log in to post comments
.png)
.png)
.png)

.png)

.png)
.png)