Solved

Excel 2010 - Convert Improper Date to Proper Date

Posted on 2013-01-24
11
941 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

759 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

21 Experts available now in Live!

Get 1:1 Help Now