Get the Date of a DateTime in SQL Server

5. August 2007

Pretty simple really. Try this SQL:

SELECT CONVERT(nvarchar(20), GetDate(), 101);

or

SELECT CONVERT(nvarchar(20), CAST(’2008-04-04 16:07:07.920′ AS DateTime), 101);

If you need to use it in a comparison you can easily do something like

WHERE CONVERT(nvarchar(20), MyDateColumn, 101) BETWEEN @DateFrom AND @DateTo

Enjoy!

SQL Server

Comments

3/2/2010 11:19:31 PM #
Zahvaljujemo se vam za dobro delovno mesto najlep?a hvala

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading