SQL Server equivalent of MySQL's NOW()?
getdate()
or getutcdate()
.
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
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.