PDA

View Full Version : Solved: extract birth date from code and calculate the age



nedy_03
09-26-2007, 05:26 AM
Hello,

i have a bata base in acces 2003. In one field a code witch contains the birth date of the person:
1861003080018
1- means that is a male
861003 - means that he was born on 10-oct-1986

In one column I have this codes and next to it I would need a colum that extracts the birth date from this code./

And on another column to calculate how old that person is (exemple 18 )

Is it possible ? .. Can anibody help on that ?

thxx,
nedy

Oorang
09-26-2007, 06:53 AM
861003 - means that he was born on 10-oct-1986
I assume you mean 03-oct-1986? Anyway, if your field name is "code",you can calculate DOB like this:
DOB: DateSerial(Mid([code],2,2),Mid([code],4,2),Mid([code],6,2))
You can calculate age like this:
Age: Year(Date())-CLng(Mid([FreeText],2,2))-1900
I think it's important to note that your system if going to break when it starts encountering people born after 12/31/1999.

nedy_03
09-27-2007, 06:09 AM
Thx