Solved

convert to datetime  yyyymmdd format

Posted on 2009-06-30
2
1,372 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now