Syntax for shortening Datetime

I have a Column in a table that stores the date.  The formating on it is datetime.  I pull from this column for a description that I put in another table.  The description includes other thing in the string so I store it as varchar.  Problem is when I cast the datetime as varchar to store it has the date 10/21/2008 12:00AM.  I don't need the time on there but not sure how to get rid of it since I'm casting it as a varchar.
LVL 12
Nathan RileyFounder/CTOAsked:
Who is Participating?
 
SStoryConnect With a Mentor Commented:
convert(varchar,ColName,101)

This should do it...convert a DateTime field named ColName to a varchar using style 101
See this table:
http://msdn.microsoft.com/en-us/library/ms187928.aspx
0
 
MikeTooleConnect With a Mentor Commented:
What you need is the TSQL Convert() function which takes a third parameter for dates to specify the style of the date. E.g. for US dates:
select convert(varchar(10), getdate(),101)
Gives:
10/21/2008
 
0
 
jamesguConnect With a Mentor Commented:
since you've had the string, do this

select cast( cast('10/21/2008 12:00AM' as varchar(10)) as datetime)

0
All Courses

From novice to tech pro — start learning today.