
DECLARE @UptimeSeconds INT;
DECLARE @StartTime DATETIME;

SELECT @StartTime = sqlserver_start_time FROM sys.dm_os_sys_info;
SET @UptimeSeconds = DATEDIFF(SECOND, @StartTime, GETDATE());

SELECT 
    @StartTime AS [Server Start Time],
    GETDATE() AS [Current Time],
    @UptimeSeconds AS [UptimeSeconds],
    @UptimeSeconds / 86400 AS [Days],
    (@UptimeSeconds % 86400) / 3600 AS [Hours],
    (@UptimeSeconds % 3600) / 60 AS [Minutes],
    (@UptimeSeconds % 60) AS [Seconds];

