SQL Server equivalent of MySQL's NOW()?

后端 未结 4 1347
-上瘾入骨i
-上瘾入骨i 2020-12-07 17:19

I\'m a MySQL guy working on a SQL Server project, trying to get a datetime field to show the current time. In MySQL I\'d use NOW() but it isn\'t accepting that.

<         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 17:34

    SYSDATETIME() and SYSUTCDATETIME()

    are the DateTime2 equivalents of

    GetDate() and GetUTCDate()

    which return a DateTime.

    DateTime2 is now the preferred method for storing the date and time in SQL Server 2008+. See the following StackOverflow Post.

提交回复
热议问题