Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between GETDATE and SYSDATETIME

What is the difference between GETDATE and SYSDATETIME ? Which one is commonly used?

Any help is appreciated.

like image 471
CodeMachine Avatar asked Jul 20 '18 05:07

CodeMachine


1 Answers

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

like image 143
AswinRajaram Avatar answered Nov 07 '22 22:11

AswinRajaram