Quantcast
Channel: THWACK: Message List
Viewing all articles
Browse latest Browse all 20607

Re: reports - custom SQL time ranges help

$
0
0

Hello All,

 

I'm looking for some help, right now I have this:

 

DECLARE @StartDate DateTime

DECLARE @EndDate DateTime

 

 

SET @StartDate = DATEADD(d, DATEDIFF(d, 0, DATEADD(m, -1, DATEADD(d, 1 - day(getdate()), getdate()))), 0)

SET @EndDate = DATEADD(ms, -2,DATEADD(d, DATEDIFF(d, 0, DATEADD(d, 1 - day(getdate()), getdate())), 0))

 

 

SELECT Interfaces.InterfaceId,

  Nodes.NodeID,

  Nodes.Caption AS NodeName,

  Interfaces.Caption AS Interface_Caption,

  Maxbps_In95,

  Maxbps_Out95,

                Interfaces.InterfaceAlias AS Interface_Alias

 

 

FROM Nodes

INNER JOIN Interfaces ON Nodes.NodeID = Interfaces.NodeID

INNER JOIN (

  SELECT InterfaceID,

  dbo.GetInBps95th(InterfaceID, @StartDate, @EndDate) AS Maxbps_In95,

  dbo.GetOutBps95th(InterfaceID, @StartDate, @EndDate) AS Maxbps_Out95

  FROM InterfaceTraffic

  WHERE InterfaceTraffic.DateTime >= @StartDate AND InterfaceTraffic.DateTime <= @EndDate

  GROUP BY InterfaceID

) TrafficStat

ON Interfaces.InterfaceID = TrafficStat.InterfaceID

 

 

AND 

(

  (Interfaces.Caption LIKE '%Eth%') AND

  (Interfaces.Caption LIKE '%CUST:%')

)

ORDER BY NodeName, Interface_Alias

 

but instead of using this:

 

SET @StartDate = DATEADD(d, DATEDIFF(d, 0, DATEADD(m, -1, DATEADD(d, 1 - day(getdate()), getdate()))), 0)

SET @EndDate = DATEADD(ms, -2,DATEADD(d, DATEDIFF(d, 0, DATEADD(d, 1 - day(getdate()), getdate())), 0))

 

I want to try to integrate this

 

Convert(DateTime,Floor(Cast((DateTime) as Float)*24)/24,0),

 

into the SQL so I can split up the report based on hours.

 

Any help is appreciated!


Viewing all articles
Browse latest Browse all 20607

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>