Transact SQL Other Articles Software Reviews
SQL Server Help: Find the date today in Microsoft's Transact SQL
To get the date today in SQL use the GetDate() function. This function returns the date today as a DateTime data type:
SELECT GetDate() AS 'DateToday'
Getting the current date (and/or time) in SQL Server's SQL is easy - just use the GetDate function. This can be used to show the current date:
SELECT GetDate() AS 'CurrentDate'
To make a variable holding the date today, use something like the following transact SQL code:
DECLARE @DateToday DATETIME
Today's date can be used in other queries such as select queries:
SELECT * FROM t_Products WHERE UseByDate = GetDate()