Solved

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

Posted on 2004-09-02
5
1,845 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
  • 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 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

18 Experts available now in Live!

Get 1:1 Help Now