What is the difference between GETDATE
and SYSDATETIME
? Which one is commonly used?
Any help is appreciated.
What is the difference between GETDATE
and SYSDATETIME
? Which one is commonly used?
Any help is appreciated.
For GETDATE
the precision is till miliseconds and in case of SYSDATETIME
the precision is till nanoseconds.
SELECT GETDATE() fn_GetDate, SYSDATETIME() fn_SysDateTime
yields
fn_GetDate fn_SysDateTime
----------------------- ---------------------------
2018-07-20 11:07:26.403 2018-07-20 11:07:26.3980117
DATETIME
is commonly used as higher precision corresponds to lower efficiency(marginally) in case of SYSDATETIME
SYSDATETIME and SYSUTCDATETIME is more precise, i.e.. has more fractional seconds than GETDATE()
GETDATE() Is more generally used when you don't need that much precision
Ex:
SELECT SYSDATETIME() Results 2007-04-30 13:10:02.0474381
SELECT GETDATE() Results 2007-04-30 13:10:02.047