Question

I have received raw data that has a column of data with the following date and time stamp format:

Mar 31 2014 3:38AM

The format of the cells are not consistent as some have single spaces and others have double or triple spaces in them between characters. So I generated a formula to give me single spaces. However when I use the "dateValue" or "TimeValue" to convert the cell to a value I can use (add dates / times) I'm getting a #value ref.

I have read a number of answers on this and tried a few tips but I can't get it working. Any thoughts would be greatly appreciated.

Was it helpful?

Solution

you can use an UDF to achieve this with custom formatted dates. Open VBE and add a standard module. Copy and paste those two functions to the module

Function MyDateValue(r As Range) As String
    MyDateValue = DateValue(CDate(r))
End Function

Function MyTimeValue(r As Range) As String
    MyTimeValue = TimeValue(CDate(r))
End Function

Now go back to your spreadsheet and enter

=MyDateValue(A1)

and

=MyTimeValue(A1)

you should be getting the correct values

enter image description here

OTHER TIPS

Try adding a comma to the date string, that works for me when I reproduce your issue.

Mar 31, 2014 3:38AM

I used a formula:

=SUBSTITUTE(B7," 2014",", 2014")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top