Trying to query for everything last month. This bit works great in SQL...what is the equivalent in SWQL?
DateTime BETWEEN DATEADD(MONTH,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) AND DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))
Did you look at Date/Time Functions on the Orion SDK wiki?
He said 'Last month, so maybe:
SELECT i.INTERFACEID,i.OutPercentUtil,i.Datetime
FROM Orion.NPM.InterfaceTraffic i
--WHERE i.interfaceid = '10075' AND ((i.DateTime BETWEEN DATEADD(MONTH,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) AND DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) <- SQL
WHERE i.interfaceid = '10075' AND (i.DateTime BETWEEN (adddate ('month',-1,GETDATE())) and GETDATE()) -- <- SWQL
ORDER BY DATETIME DESC
I think this is the logic you'd want for the WHERE clause:
WHERE DateTime BETWEEN DATETRUNC('month', AddDate('month', -1, GETDATE())) AND DATETRUNC('month', GETDATE())
SELECT i.InterfaceId , i.OutPercentUtil , i.Datetime , AddDate('month', -1, GETDATE()) AS [OneMonthAgo] , DATETRUNC('month', AddDate('month', -1, GETDATE())) AS [BeginDate] , DATETRUNC('month', GETDATE()) AS [EndDate] FROM Orion.NPM.InterfaceTraffic AS i WHERE DateTime BETWEEN DATETRUNC('month', AddDate('month', -1, GETDATE())) AND DATETRUNC('month', GETDATE()) AND i.InterfaceId = 1119 ORDER BY DATETIME DESC
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 195,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.