*--------------------------------------------------- PROCEDURE makedate(tuD, tlFuture) *[2016/06/28 14:54:15] ndragan - added future for expiry dates. LOCAL ldD, lny DO CASE CASE EMPTY(tuD) ldD={} CASE VARTYPE(tuD)$"T" ldD=TTOD(tuD) CASE VARTYPE(tuD)$"D" ldD=tuD CASE VARTYPE(tuD)="C" DO CASE CASE LEN(tuD)<6 OR NOT ISDIGIT(tuD) ldD={} oLog.LOG(tuD+" in a date field") oCnt.ADD("Date field contains "+tuD) CASE NOT ISDIGIT(GETWORDNUM(tuD,2," -./")) lcMo=GETWORDNUM(tuD,2," -./") lnMo=ROUND(ATC(lcMo, "dum jan feb mar apr may jun jul aug sep oct nov dec ")/4,0) lnDay=VAL(GETWORDNUM(tuD,1," -./")) lnYear=VAL(GETWORDNUM(tuD,3," -./")) IF lnYear<100 lnYear = lnYear + IIF(BETWEEN(lnYear, 1, 25), 2000, 1900) ENDIF ldD=DATE(lnYear, lnMo, lnDay) CASE LEN(tuD)>10 ldD=TTOD(CTOT(tuD)) OTHERWISE ldD=CTOD(tuD) ENDCASE OTHERWISE ldD={} ENDCASE lny=YEAR(ldD) *[2014/03/03 10:03:26] nDragan - there are about fifty cases where dates of birth are in wrong century DO CASE CASE NOT tlFuture AND BETWEEN(lny, 2030, 2090) ldD=DATE(1900+lny%100, MONTH(ldD), DAY(ldD)) oCnt.ADD("Fixed date in century "+TRANSFORM(lny-lny%100)) CASE BETWEEN(lny, 130, 199) ldD=DATE(1900+lny%100, MONTH(ldD), DAY(ldD)) oCnt.ADD("Fixed date in century "+TRANSFORM(lny-lny%100)) CASE BETWEEN(lny, 200,219) ldD=DATE(2000+lny%100, MONTH(ldD), DAY(ldD)) oCnt.ADD("Fixed date in century "+TRANSFORM(lny-lny%100)) CASE BETWEEN(lny, 1, 1790) ldD=DATE(1900+lny%100, MONTH(ldD), DAY(ldD)) oCnt.ADD("Fixed date in century "+TRANSFORM(lny-lny%100)) * CASE lny>2100 ENDCASE RETURN ldDThe oCnt is a collection, and the .add() method maintains a counter for each string passed, so the items are string+number (of occurrences) pairs. In the end it logs each of them. You can remove the oCnt lines and oLog lines as well - I keep them just to check the number of irregular cases in the sheets. If more than a hundred, then I adjust the code; below hundred, I recommend that they fix it manually afterwards.