November 21, 2022 at 12:00 am
Comments posted to this topic are about the item Checking Time
November 21, 2022 at 5:04 am
The correct answer is... none of the above because because the method is unreliable. After 25 days, 20 hours, 31 minutes, and 23.649 seconds (-2147483649 ms), the DATEADD() will fail due to an INT overflow condition.
NEVER use the method posted.
As a bit of a sidebar, you have to wonder what MS was thinking when they made a DATEDIFF_BIG() but didn't make a DATEADD_BIG(), even for 2022! 🙁 As a wise man once said, "ZOMGWTFBBQ!!!11!11!shiftone!!!!!"
--Jeff Moden
Change is inevitable... Change for the better is not.
November 21, 2022 at 4:57 pm
SELECT DATEADD(SECOND, -sample_ms/1000, GETDATE()), *
FROM sys.dm_io_virtual_file_stats ( 1,1)
or
SELECT DATEADD(mi, -sample_ms/1000000, GETDATE()), *
FROM sys.dm_io_virtual_file_stats ( 1,1)
--------------------------------------
;-)“Everything has beauty, but not everyone sees it.” ― Confucius
November 21, 2022 at 9:46 pm
SELECT DATEADD(SECOND, -sample_ms/1000, GETDATE()), * FROM sys.dm_io_virtual_file_stats ( 1,1)
or
SELECT DATEADD(mi, -sample_ms/1000000, GETDATE()), * FROM sys.dm_io_virtual_file_stats ( 1,1)
Heh... instead of picking through the manure trying to figure out what the horse was thinking, let's walk around to the front of the horse and ask the horse! 😀
SELECT sqlserver_start_time FROM sys.dm_os_sys_info;
Another way to do it (and guaranteed to be instance specific) is...
SELECT create_date FROM sys.databases WHERE name = 'tempdb';
--Jeff Moden
Change is inevitable... Change for the better is not.
November 30, 2022 at 12:22 am
this system table may give diff. date time.
--------------------------------------
;-)“Everything has beauty, but not everyone sees it.” ― Confucius
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply