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
Solved

convert to datetime  yyyymmdd format

Posted on 2009-06-30
2
1,378 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
2 Comments
 
LVL 75

Accepted Solution

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

Assisted Solution

by:EugeneZ
EugeneZ earned 20 total points
ID: 24747201
you can try

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

856 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