Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting date format

Status
Not open for further replies.

sinCity99

Programmer
Jan 21, 2009
20
0
0
US
Hi,

I need to convert a date 20091011 to 10/11/2009.

This is how i'm converting it:
convert(varchar,cast(ap.appt_date as dateTime),101) as Date

but my return is 10/11/20

it keeps leaving out the last two numbers of the year.
 
yes i did change varchar to varchar(10) but that didn't do anything either.
 
sin,
For me:
Code:
select convert(varchar(10),cast('20091011' as datetime),101)
Returns:
10/11/2009
in sql 2005
 
Sin,

Try this
Code:
select convert(varchar,(convert (datetime, ap.appt_date)), 101) as 'Date'

HTH,

M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top