Solved

convert to datetime  yyyymmdd format

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

757 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

21 Experts available now in Live!

Get 1:1 Help Now