Convert YYYYMMDD as a Char(8)  to DD/MM/YYYY varchar(10) in SQL 2k

Posted on 2004-09-02
Last Modified: 2007-12-19
I imported a table in which the date format is YYYYMMDD Char(8) and I need to convert the
date to the DD/MM/YYYY varchar(10) format.  Is there an update statement or something
equivalent to make this conversion painless?  Thanks for your help.
Question by:Chuck_aa
  • 3
  • 2
LVL 11

Expert Comment

ID: 11965040
select convert(varchar(20),getdate(),103)

this will give you the date in dd/mm/yyyy format.
LVL 11

Accepted Solution

ram2098 earned 500 total points
ID: 11965049
sorry..change it to varchar(10)..
select convert(varchar(10),getdate(),103

Expert Comment

ID: 11965122
SELECT CAST((substring(@cDate,7,2)+'/'+substring(@cDate,5,2)+'/'+ substring(@cDate,1,4)) as nvarchar(10))
LVL 11

Expert Comment

ID: 11965133
Replace getdate() the date in your table...

select convert(varchar(10),yourdatefield,103)

Expert Comment

ID: 11965135
oops, where @cDate is your column name:)

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQl Query 4 31
Syntax Error in Query 7 30
T-SQL:  What won't it just collapse?  It would be the logical thing to do! 20 44
Sql Join Problem 2 18
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

948 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