We are using an API query to pull historical CPU/memory historical data for a select group of servers. The query works as expected for detail and hourly stats, but the data only retrieves as far back as the hourly stats are kept (100 days in our environment). We would like to include the daily stats as well which go back a full calendar year. How do I need to modify the PW script below to include daily stats?
$startDate = '10/01/2021'
$endDate = '03/31/2022'
$swql = "SELECT N.Caption AS Hostname, SUBSTRING( REPLACE(N.SysName, 'xxxxx', ''), 0, LENGTH(REPLACE(N.SysName, 'xxxxx', '')) - 1) AS System, C.DateTime AS Datetime, ROUND( C.MaxLoad, 0 ) AS CPULoad, ROUND( C.MaxMemoryUsed, 0 ) AS Memory " +
"FROM Orion.CPULoad C " +
"INNER JOIN Orion.Nodes N ON N.NodeID = C.NodeID " +
"WHERE N.NodeID IN( $Outstring ) " +
"AND ( C.DateTime >= '$startDate' AND C.DateTime 8 )" +
"AND ( HOUR( C.DateTime ) < 20 ) " +
"AND ( WEEKDAY( C.DateTime ) IN ( 1, 2, 3, 4, 5 ) )" +
"ORDER BY N.NodeID, C.DateTime"