Solved

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

Posted on 2004-09-02
5
1,863 Views
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.
0
Comment
Question by:Chuck_aa
[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
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

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

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

Accepted Solution

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

Expert Comment

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

Expert Comment

by:ram2098
ID: 11965133
Replace getdate() below..to the date in your table...

select convert(varchar(10),yourdatefield,103)
0
 
LVL 7

Expert Comment

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
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…

739 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