SQL Server equivalent of MySQL's NOW()?

后端 未结 4 1354
-上瘾入骨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:55

    getdate() 
    

    is the direct equivalent, but you should always use UTC datetimes

    getutcdate()
    

    whether your app operates across timezones or not - otherwise you run the risk of screwing up date math at the spring/fall transitions

提交回复
热议问题