Solved

How do i convert these from text to date??

Posted on 2011-03-22
4
244 Views
Last Modified: 2012-05-11
Hi,
Using Excel 2007; i've imported a huge CSV file into Excel.

There is a column with thousands of 'date' entries, but for some reason Excel is not seeing them as dates.

They are entered like this:

 19/01/2011 02:45:01 pm
 19/01/2011 02:42:35 pm
 19/01/2011 02:40:14 pm
 19/01/2011 02:39:23 pm
 19/01/2011 02:39:08 pm
 19/01/2011 02:34:52 pm
 19/01/2011 02:29:55 pm
 19/01/2011 02:20:19 pm

I'm trying to sort them by date in a pivot table, but they won't sort correctly, because Excel doesn't see them as dates.

How do I convert them to date fields?  I don't need the 'second', but I do need the day, month, year, and then the time (03:50, 04:01, etc)

Any suggestions?
0
Comment
Question by:Mystical_Ice
  • 3
4 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 400 total points
Comment Utility
Try this formula on the dates in a separate column:

   =DATE(MID(A2,7,4),MID(A2,4,2),LEFT(A2,2))

Kevin
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
Comment Utility
To include the time:

   =DATE(MID(A2,7,4),MID(A2,4,2),LEFT(A2,2))+TIMEVALUE(MID(A2,13,11))

Kevin
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
Comment Utility
A macro that will convert the selected dates:

Public Sub CleanDates()

    Dim Cell As Range
   
    For Each Cell In Selection
        If Left(Cell, 1) = Chr(160) Then Cell = Mid(Cell, 2)
        Cell = DateSerial(Mid(Trim(Cell), 7, 4), Mid(Trim(Cell), 4, 2), Left(Trim(Cell), 2)) + TimeValue(Mid(Trim(Cell), 13, 11))
    Next Cell

End Sub

Kevin
0
 
LVL 50

Assisted Solution

by:barry houdini
barry houdini earned 100 total points
Comment Utility
You can use "Text to columns" functionality

Select column of dates

Data > Text to columns > Next > Next > under "column data format" select "date" and the source format from the dropdown, i.e. DMY > Finish

Then you can format them any way you want

regards, barry
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

771 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

10 Experts available now in Live!

Get 1:1 Help Now