Brettb.Com
  HOME | ABOUT ME | BIOTECHNOLOGY | ARTICLES | GALLERY | CONTACT
Search: Go
TECHNICAL ARTICLES
 ASP
 ASP.NET
 JavaScript
 Transact SQL
 Other Articles
 Software Reviews

PHOTO GALLERIES
 Canon EOS 300D Samples
 Akihabara Maids!
 More Galleries...

TRAVEL LOG
 2009: China
 2008: Tokyo
 2007: Tokyo
 2006: Hong Kong
 2005: New York City

MORE STUFF
 Search Engine Optimisation
 Build an ASP Search Engine
 My Tropical Fishtank
 Autoglass
 SQL Month Name
 SQL Get Date Today
 SQL Year Month
 Other New Stuff...

POPULAR STUFF
 Regular Expressions
 Index Server & ASP
 JavaScript Ad Rotator

Home > Articles > Transact SQL Programming Articles

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
SELECT @DateToday = GetDate()
SELECT 'Today''s date is ' + convert(varchar(20), @DateToday)

Today's date can be used in other queries such as select queries:

SELECT * FROM t_Products WHERE UseByDate = GetDate()

Useful Links

  • The SQL Documentation Tool automatically builds technical documentation for Microsoft SQL Server databases, saving you time and money. A trial version is available for download.

  Site Map | Privacy Policy

All content is 1995 - 2012