How do I calculate age using a 13 digit social security number where the the
first six digits is DOB (yy/MM/dd). I tried Select Left 6 digits and calling
that DOB and then do DateDiff but this DOB field is not date format. Can
anyone help. I am using Access 2003.
Rick B - 26 Apr 2005 21:23 GMT
Ummmm Social Security numbers do not include a birthdate. (Unless they have
"social security numbers" outside the US and I am not aware of it. My
social Security number is 452-XX-XXXX. I was born in December of 1968.
If that is the case, I'm sure there is a way to turn a six-digit number into
a date. I have seen it posted out here before. It seems like it put the
digits into the "date serial" somehow. Once you got that, you'd use the
following to calcualte age.
The proper formula to calculate Age is...
DateDiff("yyyy",[Birthdate],Date())+(Format([Birthdate],"mmdd")>Format(Date(
),"mmdd"))

Signature
Rick B
> How do I calculate age using a 13 digit social security number where the the
> first six digits is DOB (yy/MM/dd). I tried Select Left 6 digits and calling
> that DOB and then do DateDiff but this DOB field is not date format. Can
> anyone help. I am using Access 2003.
Rick B - 26 Apr 2005 21:24 GMT
Just saw that you said 13-digit. Obviously not a US social security (they
are 9 digits). Disregard the first part of my post.

Signature
Rick B
> How do I calculate age using a 13 digit social security number where the the
> first six digits is DOB (yy/MM/dd). I tried Select Left 6 digits and calling
> that DOB and then do DateDiff but this DOB field is not date format. Can
> anyone help. I am using Access 2003.
Brendan Reynolds - 26 Apr 2005 21:51 GMT
You could use the DateSerial function ...
?
dateserial(cint(left$("050101",2)),cint(mid$("050101",3,2)),cint(mid$("050101",5,2)))
01/01/2005
Note, though, that the format is not Y2K compatible. There is no way to tell
whether someone with a number begining '050101' is three months old (1 Jan
2005) or 100 years old (1 Jan 1905).

Signature
Brendan Reynolds (MVP)
> How do I calculate age using a 13 digit social security number where the
> the
> first six digits is DOB (yy/MM/dd). I tried Select Left 6 digits and
> calling
> that DOB and then do DateDiff but this DOB field is not date format. Can
> anyone help. I am using Access 2003.
Pavel Romashkin - 26 Apr 2005 21:53 GMT
Perhaps you could enclose the string into # signs to signify that it is
a date?
Cheers,
Pavel
> How do I calculate age using a 13 digit social security number where the the
> first six digits is DOB (yy/MM/dd). I tried Select Left 6 digits and calling
> that DOB and then do DateDiff but this DOB field is not date format. Can
> anyone help. I am using Access 2003.
Tim Ferguson - 27 Apr 2005 17:27 GMT
>> How do I calculate age using a 13 digit social security number where
>> the the first six digits is DOB (yy/MM/dd). I tried Select Left 6
>> digits and calling that DOB and then do DateDiff but this DOB field
>> is not date format.
> Perhaps you could enclose the string into # signs to signify that it
> is a date?
No: I she really means the first six digits then it's not going to be a
legitimate date format in any language ("031225") with or without the
hash marks.
Chopping out the digits and passing them to DateSerial is the only safe
method.
All the best
Tim F
Haris Rashid - 29 Apr 2005 19:32 GMT
hi,
Here is how to achieve it:
Step 1: Separate the part of the number that are the date:
Use the function Left(string, length). It returns a Variant (String)
containing a specified number of characters from the left side of a string.
Example MyStr = Left(SSN, 6)
Step 2: Converting the 6 digits to date
Repeat the LEFT function and store the values in variables say SSN_DAY,
SSN_MONTH, SSN_YEAR
Step 3: The DOBDepending upon which date format you are using on your PC
(relative to the global settings in Windows) adjust whether you need the day
first or the month first.
Get DOB as SSN_DOB=SSN_DAY & "-" & SSN_MONTH & "-" & SSN_YEAR
Now apply IsDate Function to SSN_DOB to check that this indeed is a date.
Convert it to date as SSN_DOB= CDate(SSN_DOB)
Use the date diff function with the SSN_DOB and it should return the age
Age= DateDiff("y", Now, SNN_DOB)
---------------
Haris Rashid
http://www.manage-systems.com
----------------------------------------
> How do I calculate age using a 13 digit social security number where the the
> first six digits is DOB (yy/MM/dd). I tried Select Left 6 digits and calling
> that DOB and then do DateDiff but this DOB field is not date format. Can
> anyone help. I am using Access 2003.