Posts
1150
Comments
891
Trackbacks
1
T-SQL: How do I get only the date?

Getdate() returns the date and the time.  What if you only want the date?

Well, you can't, at least not as a 'date-only' datatype, but you can get a varchar these ways:

select convert(varchar,getdate(),101) -- change the 101 to get different formatting

or

select convert(varchar,datepart(yy,getdate())) + '-' + convert(varchar,datepart(mm,getdate())) + '-' + convert(varchar,datepart(dd,getdate()))

posted on Thursday, August 25, 2005 9:14 AM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 3 and 7 and type the answer here: