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
6/3/2010 2:54:44 PM #
Not many people would say this.  Youve got some guts.  I will say this, though.  If you dont want to alienate any readers, youre gonna have to stop generalising so much.  Maybe you should try seeing both sides of this issue instead of assuming that yours is the only valid opinion.  Id still read it, I like the way you write.  But I can see some people getting upset.
6/16/2010 11:46:25 AM #
This is my second visit to this blog. We are starting a new initiative in the same category as this blog. Your blog provided us with valuable information to work with. You have done a marvellous job.

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading