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 Chriss Miller 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
Joined
Jan 21, 2009
Messages
20
Location
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.
 
Change varchar to varchar(10)
--Jim
 
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
 
I was trying to figure out what setting or what format to apply to change this (since for me the above code returned 4 digits for year), but didn't find it yet so far.

You can also check this link

but quickly browsing through it I could not find the info.
 
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