• I also had an issue with usp_Main_GetSessionInfo due to the max value for milliseconds in the DateDiff function being less than 24 Days (etc). Therefore, to maintain a good degree of accuracy still (and having had the problem before), I rewrote it like so :-

    USE [msdb]

    GO

    ALTER PROCEDURE [MS_PerfDashboard].[usp_Main_GetSessionInfo]

    AS

    BEGIN

    SELECT COUNT(*) AS num_sessions,

    SUM(s.total_elapsed_time) AS total_elapsed_time,

    SUM(s.cpu_time) AS cpu_time,

    SUM(s.total_elapsed_time) - SUM(s.cpu_time) AS wait_time,

    SUM(s.login_time) - SUM(s.total_elapsed_time) AS idle_connection_time,

    cache_hit_ratio=(CASE WHEN SUM(s.logical_reads) > 0 THEN (SUM(s.logical_reads) - ISNULL(SUM(s.reads),0)) / CONVERT(FLOAT,SUM(s.logical_reads))

    ELSE NULL END)

    FROM (SELECT session_id,

    CONVERT(BIGINT,total_elapsed_time) AS total_elapsed_time,

    CONVERT(BIGINT,cpu_time) AS cpu_time,

    CONVERT(BIGINT,DATEDIFF(ss,login_time,GETDATE()))*1000 AS login_time,

    logical_reads, reads

    FROM sys.dm_exec_sessions

    WHERE is_user_process = 0x1

    AND login_timeDATEADD(minute,-35791,GETDATE())) s

    END