Solved

Excel 2010 - Convert Improper Date to Proper Date

Posted on 2013-01-24
11
965 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:d2beetle
  • 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
 
LVL 26

Accepted Solution

by:
redmondb earned 125 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:d2beetle
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 13

Assisted Solution

by:Shanan212
Shanan212 earned 125 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:d2beetle
ID: 38818816
redmondb and Shanan212,

Thanks, :) points split evenly.
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38819084
Thanks, d2beetle!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

948 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

22 Experts available now in Live!

Get 1:1 Help Now