• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

Converting text to date

I have a table with dates that are stored as text:

021204
981112
000317

I want to convert the text to dates like this:

12/04/2002
11/12/1998
03/17/2000

I'm sure this should be quick and easy...I just can't seem to do it. Thanks!
0
BI_Dunce
Asked:
BI_Dunce
2 Solutions
 
fhillyer1Commented:
example : SELECT CONVERT(DATETIME, CONVERT(CHAR(8), 20070824))
0
 
ralmadaCommented:
In MS-Access try this:
select format(dateserial( left(yourcolumn, 2), mid(yourcolumn, 3, 2), right(yourcolumn, 2)), "MM/DD/YYYY")

Open in new window

0
 
pteranodon72Commented:
In a query, create a field, strYYMMDD,

DateField: DateSerial(left(strYYMMDD,2), Mid(strYYMMDD,3,2),Right(strYYMMDD,2))


HTH,
pT72

0
 
fhillyer1Commented:
one question, do you want to convert them on the runtime or do you want to convert a column in your table?

0
 
BI_DunceAuthor Commented:
Both solutions worked, but pteranodon72's code was shorter and simpler. Thanks guys!! Much appreciated
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

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