0

I have a spreadsheet which contains the loading times for my website. I want to find the peak hour for my website.

However the dates are stored in the following format:

Jun 02, 2014 01:13:08 am
MMM DD, YYYY HH:MM:SS am / pm

How can I convert this in to date that excel will understand?

fedorqui
  • 275,237
  • 103
  • 548
  • 598
danstan
  • 95
  • 3
  • 11
  • You could change the cell formatting. – Matthijs Jun 02 '14 at 09:04
  • I've tried that, excel still does not see it as a date – danstan Jun 02 '14 at 09:05
  • Do you have an English language version of Excel? If so, there may be a non-printing character in the string -- probably a NBSP (ASCII 160). Try doing a Find/Replace to remove those characters. – Ron Rosenfeld Jun 02 '14 at 09:09
  • As a test, can you tell me what you get as a result of the formula: =A1+0 when A1 contains a slight modification to your string example: 02 Jun, 2014 01:13:08 am (be sure to format the cell as text before entering this string)? – XOR LX Jun 02 '14 at 09:30
  • See http://stackoverflow.com/questions/23587037/excel-vba-extract-the-correct-dates-from-badly-formatted-dates – MP24 Jun 02 '14 at 09:47

3 Answers3

3

To convert your "pseudo-dates" into real dates, select them and run:

Sub ConvertDates()
    Dim r As Range
    For Each r In Selection
        r.Value = CDate(r.Text)
    Next r
End Sub
Gary's Student
  • 95,722
  • 10
  • 59
  • 99
0

Another solution - via change in windows regional settings.

before/after

Start with .CVS file with date in MMM DD", "YYYY HH:MM:SS AM/PM

In windows 10, Open:

Control Panel > Clock and Region > Region

In long date, enter MMM dd,yyyy > OK.

Windows regional settings

Reboot, then open the excel file, the text is recognized as date.

Toni
  • 1,555
  • 4
  • 15
  • 23
Shahar
  • 1
  • 1
-2
=TEXT(DATEVALUE(MID(A1,4,FIND(",",A1)-4)&"/"&MONTH(LEFT(A1,3)&1)&"/"&MID(A1,FIND(",",A1)+2,4))+TIMEVALUE(RIGHT(A1,8)),"dd/mm/yyyy hh:mm")
jmoerdyk
  • 5,544
  • 7
  • 38
  • 49
Helper
  • 1
  • While this code may solve the question, [including an explanation](https://meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply – jmoerdyk Jan 19 '23 at 16:14