Converting Dates to 8 digits
I've assumed that your dates are in A1 (down) of sheet1, and you want
the (composite) response in B1. Insert a new sheet (Sheet2) and enter
these formulae:
A1:
=IF(LEFT(Sheet1!A1,1)="0",RIGHT(Sheet1!A1,LEN(Shee t1!A1)-1),Sheet1!A1)
This strips any leading zeroes from your dates if they are text.
C1:
=IF(LEN(A1)=4,"0"&LEFT(A1,1)&"0"&MID(A1,2,1)&"19"& RIGHT(A1,2),IF(LEN(A1)=8,A1,""))
This checks for 4-digit or 8-digit dates - these are unambiguous.
D1:
=IF(LEN(A1)<5,"",IF(VALUE(MID(A1,2,1))2,"0"&LEFT (A1,3)&"19"&RIGHT(A1,2),
IF(VALUE(LEFT(A1,1))1,"0"&LEFT(A1,3)&"19"&RIGHT(A 1,2),"check")))
Column D checks for 5-digit dates - I've broken the formula to avoid
awkward line-breaks.
E1:
=IF(LEN(A1)<6,"",IF(MID(A1,3,2)<"19",LEFT(A1,4)& "19"&RIGHT(A1,2),
IF(VALUE(LEFT(A1,1))1,"0"&LEFT(A1,1)&"0"&RIGHT(A1 ,5),"check")))
Column E is for 6-digit dates.
F1: =IF(LEN(A1)<7,"",IF(VALUE(MID(A1,2,1))2,"0"&A1,
IF(LEFT(A1,2)="10",LEFT(A1,2)&"0"&RIGHT(A1,5),
IF(VALUE(LEFT(A1,1))1,"0"&A1,"check"))))
Column F checks 7-digit dates. I have not built in any checks for <
4-digit or 8-digit. Finally in this sheet:
B1: =C1&D1&E1&F1
This holds the appropriate output. I would suggest that you use
conditional formatting on this - if Cell Contents, Equal To, "check"
then change the background colour to something gawdy. All these
formulae can be copied down for as many dates as you have in sheet1.
One final formula in sheet1 cell B1:
=""&Sheet2!B1
I would suggest that you work on Sheet2, examining any values of
"check" in column B and entering your own interpretation of the date as
applicable - you should enter an apostrophe first in order to preserve
any leading zeroes (the output is text). Then when you have all the
dates in the correct format, you can fix the values in column B of
sheet1.
There may be a few more unambiguous combinations which others can
identify, and these can be built into the formulae quite easily.
Hope this helps to reduce your workload.
Pete
|