8

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

Any help is appreciated.

AswinRajaram
  • 1,519
  • 7
  • 18
CodeMachine
  • 260
  • 2
  • 4
  • 10
  • 3
    The very first Google search result answers your question: https://blog.sqlauthority.com/2010/06/10/sql-server-difference-between-getdate-and-sysdatetime/ – Tim Biegeleisen Jul 20 '18 at 05:36
  • 3
    I am thinking about the day that Google has not survived and Stackoverflow has, at that day this question is worth it but seriously it's good to have a more complete SO even if the question and answer are present on other places, many people like me would rather to check SO first, because it loads faster and has a better community than most other websites. Don't you agree? – Mahdi Tahsildari Jan 02 '21 at 10:01
  • 2
    The very first Google search result brought me to this question! – jamheadart Mar 05 '21 at 15:52

2 Answers2

9

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

AswinRajaram
  • 1,519
  • 7
  • 18
0

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