• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1387
  • Last Modified:

convert to datetime yyyymmdd format

I have a field in SQL that's formatted like 06/16/2009 and I want to convert to 20090616

the field is formatted as Varchar... how do I do that?

2 Solutions
Aneesh RetnakaranDatabase AdministratorCommented:
select CONVERT(varchar, CONVERT(datetime, '06/16/2009', 101), 112)
Eugene ZCommented:
you can try

select replace(convert(varchar(10), cast('06/16/2009' as datetime),121),'-','')
--result 20090616
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now