[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

convert to datetime  yyyymmdd format

Posted on 2009-06-30
2
Medium Priority
?
1,385 Views
Last Modified: 2012-05-07
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?

thanks
0
Comment
Question by:ezzadin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 120 total points
ID: 24747186
select CONVERT(varchar, CONVERT(datetime, '06/16/2009', 101), 112)
0
 
LVL 43

Assisted Solution

by:Eugene Z
Eugene Z earned 80 total points
ID: 24747201
you can try

select replace(convert(varchar(10), cast('06/16/2009' as datetime),121),'-','')
 
--result 20090616
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
What we learned in Webroot's webinar on multi-vector protection.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question