?
Solved

Excel 2010 - Convert Improper Date to Proper Date

Posted on 2013-01-24
11
Medium Priority
?
1,100 Views
Last Modified: 2013-01-25
I have searched for Excel Date Converting, but all of the search results translates that to cell "Date" Formatting. It is nice to know how many methods of date cell formatting there are, but none of these methods solve my problem ...

I am frequently sent spreadsheets that have the Date as "20130124" and it is Formatted as "General"; re-formatting the cell as any Date Format yields "#############".

What can I do to convert the date from 20130124 to 01/24/2013, so I can use the "Short Date" Cell Format?
0
Comment
Question by:Frank Bryant
[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
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 15

Expert Comment

by:Ess Kay
ID: 38815733
copy the column

then right click the column, select format, select the date format and what type you like

then paste the data back into column

hope that helps
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38815801
Use this formula and then format it as you want.
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
0
 
LVL 13

Expert Comment

by:Shanan212
ID: 38815832
Insert a column next to it
Change "G14" with your cell where the wrong date is in

=LEFT(G14,4)&"/"&MID(G14,5,2)&"/"&RIGHT(G14,2)

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
ID: 38815879
d2beetle,

"Text to Columns" can do this without a separate column...
(1) Select the cells containing the dates.
(2) On the Ribbon's Menu Bar, select Data and then "Text to Columns".
(3) Select the "Delimited" radio button (it's probably already selected).
(4) Click on "Next".
(5) Only the Tab delimiter checkbox should be selected.
(6) Click on the "Date" radio button and select "YMD" from the dropdown.
(7) Click on "Finish".

Regards,
Brian.
0
 

Author Comment

by:Frank Bryant
ID: 38816394
redmondbP,

Bingo! Thanks!

One more question, there are five other date columns in the spreadsheet that need the same conversion; is there some way to automate it via VBA/Macro?



Shanan212Po and ssaqibh

Thanks for the suggestion and it does work; however I do not want to add any more columns to the spreadsheet.



esskayb2dP,

I tried that and it did not work.
0
 
LVL 13

Assisted Solution

by:Shanan212
Shanan212 earned 500 total points
ID: 38816430
Doing it Brian's way,

Sub datemaker()
    Dim iRow As Long
    
    iRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(0, 0).Row
    
    Range("A2:A" & iRow).Select
    Selection.TextToColumns Destination:=Range("A2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
        
    Range("C2:C" & iRow).Select
    Selection.TextToColumns Destination:=Range("C2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
        
    Range("F2:F" & iRow).Select
    Selection.TextToColumns Destination:=Range("F2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
End Sub

Open in new window


To modify or add more columns, change one of these blocks (change the bold letters)

    Range("A2:A" & iRow).Select
    Selection.TextToColumns Destination:=Range("A2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38816498
Thanks, d2beetle.

Shanan212's macro looks excellent. (Trivial suggestion - the date will be wider than the original value, so it might be an idea to AutoFit the columns after the change.)

Regards,
Brian.
0
 
LVL 13

Expert Comment

by:Shanan212
ID: 38816514
Thanks Brian! It was your idea of cours :)

D2beetle,

Adding to that, this code will autofit. However you have to add/change columns below

   Range("A:A,C:C,F:F").Select
    Selection.Columns.AutoFit

Open in new window

0
 
LVL 26

Expert Comment

by:redmondb
ID: 38816627
... and your code, Shanan212!
0
 

Author Closing Comment

by:Frank Bryant
ID: 38818816
redmondb and Shanan212,

Thanks, :) points split evenly.
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38819084
Thanks, d2beetle!
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

764 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