Wednesday, March 7, 2012

quick date conversion - not hard!

im trying to convert my column of data type datetime. this is an example of what the data looks like:

2007-01-24 10:01:29.710

i want to format it as so

200701241001

ive tried this so far i think im sort of on the right track

RIGHT('000000000000' + CONVERT(varchar(20), CONVERT(int, sr.ResponseDate)),12) AS FinalDate

but its not outputting exactly what i want

thanks
andreas

Quote:

Originally Posted by andreas2410

im trying to convert my column of data type datetime. this is an example of what the data looks like:

2007-01-24 10:01:29.710

i want to format it as so

200701241001

ive tried this so far i think im sort of on the right track

RIGHT('000000000000' + CONVERT(varchar(20), CONVERT(int, sr.ResponseDate)),12) AS FinalDate

but its not outputting exactly what i want

thanks
andreas


im also thinking that i will need when i try convert

to put it into the style code either

code 20 or 120 yyyy-mm-dd hh:mi:ss(24h)

so thats 24 hour which is what i need and then rip the separators

or in code 126 below so theres no spaces, but i dont think thats 24 hr representation

code 126 yyyy-mm-dd Thh:mm:ss.mmm(no spaces)

No comments:

Post a Comment