Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1875
  • Last Modified:

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

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
Chuck_aa
Asked:
Chuck_aa
  • 3
  • 2
1 Solution
 
ram2098Commented:
select convert(varchar(20),getdate(),103)

this will give you the date in dd/mm/yyyy format.
0
 
ram2098Commented:
sorry..change it to varchar(10)..
select convert(varchar(10),getdate(),103
0
 
FDzjubaCommented:
SELECT CAST((substring(@cDate,7,2)+'/'+substring(@cDate,5,2)+'/'+ substring(@cDate,1,4)) as nvarchar(10))
0
 
ram2098Commented:
Replace getdate() below..to the date in your table...

select convert(varchar(10),yourdatefield,103)
0
 
FDzjubaCommented:
oops, where @cDate is your column name:)
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now