• You will need to convert the time aspect into a time only column then filter out where >= 6 and < 18, something like the below.

    SET NOCOUNT OFF
    SET ROWCOUNT 0
    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,
    Nodes.VendorIcon AS Vendor_Icon,
    Interfaces.Caption AS Interface_Caption,
    Interfaces.InterfaceIcon AS Interface_Icon,
    Maxbps_In95,
    Maxbps_Out95,
    Maxbps_95,
    Interfaces.InterfaceSpeed AS Interface_Speed,
    Recieve_Percentage = (Maxbps_In95 / Interfaces.InterfaceSpeed ) * 100,
    Transmit_Percentage = (Maxbps_Out95 / Interfaces.InterfaceSpeed) * 100
    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,
    dbo.GetMaxBps95th(InterfaceID, @StartDate, @EndDate) AS Maxbps_95
    FROM InterfaceTraffic
    WHERE InterfaceTraffic.DateTime >= @StartDate AND InterfaceTraffic.DateTime <= @EndDate AND CONVERT (time, InterfaceTraffic.DateTime) >= '06:00:00' AND CONVERT(time, InterfaceTraffic.DateTime) < '18:00:00'
    GROUP BY InterfaceID
    ) TrafficStat
    ON Interfaces.InterfaceID = TrafficStat.InterfaceID
    WHERE (1=1) AND
    ( (Nodes.TBU = 'TBU') AND (Interfaces.Link_Type LIKE '%Primary%') )