1

I have a date column that stores values for begining to end date as: 070314-073114 So I need to split it to 2 columns that has the Start Date as 070314 and End Date as 073114, any suggestions?

This database is still in Microsoft Access, and eventually after cleaning it up, we will move it to SQL Server.

Thanks in advance

2
  • Why do you want these as strings and not dates? Commented Jul 3, 2014 at 19:07
  • @AaronBertrand Its an old Access mdf file that I just got access to today to do some changes, so I'm not sure why they kept that column as "Text", maybe because they've been entering both start and end date together?
    – Mary
    Commented Jul 3, 2014 at 19:39

1 Answer 1

2
ALTER TABLE table ADD COLUMN Start_Date TEXT(6)
ALTER TABLE table ADD COLUMN End_Date TEXT(6)

update table
set Start_Date = Left(column,6),
End_Date = Right(column,6)
4
  • You should add some detail explaining how you could use this query... for instance, by doing an insert into another table or etc...
    – Hannah Vernon
    Commented Jul 3, 2014 at 18:22
  • 1
    @MaxVernon - something like that?
    – DavidN
    Commented Jul 3, 2014 at 18:33
  • 1
    Try to imagine looking for an answer to this exact problem several months from now, without any context. Details in the answer can help future visitors understand why, and not just how.
    – Hannah Vernon
    Commented Jul 3, 2014 at 18:49
  • Thank you all, I will try your solution after I do a backup and let you know.
    – Mary
    Commented Jul 3, 2014 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.