ExcelSavior said:
I'm working on a data file that has the date input in the
wrong format. In the date column, it shows "13-Jan". The
original format intention for this text is supposed to be
"yy-mm", or January 2013, but excel is automatically reading
it as "01/13/2012", and the format is set as "dd-mm". How
do I change the format or text so it reads the original
text correctly as "yy/mm" or "yyyy/mm" as opposed to "dd-mm"
or "mm/dd/yyyy"?
As you may understand, the problem is with the form of the input and how
Excel interprets it, not with the format of the cell. That is affected by
the Regional and Language Options control panel. No change to the format of
the cell will affect that.
You have several options to remedy the problem. Unfortunately, you neglect
to say exactly what is the form of the data file, how you are inputing it,
and what version of Excel you are using. So it is difficult to be specific.
The most obvious option is to change the short-date form in the R&LO control
panel temporarily. That is probably not a viable solution. First, it is
tedious to do. Second, it might not even be possible if you are on a shared
computer.
The second most obvious option is to let the misinterpretation happen, then
correct it with formulas later. Note that some input of the form yy-mmm,
namely when yy exceeds the last day of mmm of the current year, will not be
interpreted at all; it will be treated as text.
If the dates are in A1:A1000, you might do the following:
1. Enter the following formula in X1 (for example) and copy down through
X1000:
=IF(ISTEXT(A1),--(MID(A1,1+FIND("-",A1),99) & " 1, " & LEFT(A1,2)),
DATE(DAY(A1),MONTH(A1),1))
2. Copy X1:X1000. Paste-special-value into A1:A1000. Delete X1:X1000.
3. Format A1:A1000 as you wish.
Note-1: Replace MID(A1,1+FIND("-",A1),99) with simply RIGHT(A1,3) if we can
assume that the month abbreviation is always 3 characters.
Note-2: The MID&1&LEFT expression assumes that your long-date form is month
day, year. See your Regional and Lanaguage Options control panel settings,
and change the formula according if necessary.
I would prefer to use an expression using the DATE function. But I
discovered that DATE(13,1,1) is (mis)interpreted as 1/1/1913 even though
1/1/13 is interpreted as 1/1/2013.
A third option -- to correct the data at input time -- does not seem to
work. Ostensibly, we would use Import External Data wizard, selecting the
YMD input form in the last dialog box. But that fails to interpret yy-mmm
as year-month as intended.