SQL Server snippets

Get current DATE or DATETIME

Example 1

Use the following to get current DATE:

SELECT CONVERT(date, getdate());
Current DATE

Use the following to get current DATETIME:

SELECT getdate();
Current DATETIME

Use the following to get current DATETIME in UTC:

SELECT GETUTCDATE();
Current DATETIME UTC

You can find an interactive version of this example following this link .

Back to SQL Server cookbook page