DECLARE @Days int DECLARE @Hours int DECLARE @Mins int DECLARE @Secs int DECLARE @getdate datetime DECLARE @getdateunix int set @getdate = getdate() set @getdateunix = DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE()) SET @Secs = ( SELECT datediff(ss, login_time, getdate()) FROM master..sysprocesses WHERE spid = 1 ) SET @Days = ((@Secs/60)/60)/24 SET @Hours = ((@Secs/60)/60)%24 SET @Mins = (@Secs/60)%60 SET @Secs = @Secs%60 select @@servername as servername,@getdate as createdate,@getdateunix as createdate_unix ,@Days as days,@Hours as hours,@Mins as mins ,@Secs as secs