Convert number to date

Argus

New member
Local time
Today, 13:50
Joined
Aug 5, 2009
Messages
2
Hello, i have 11 digits number, example 37704252536. Its personal code and boldet&underlined digits are birth date. Me needs that I can from this numer to calculate age a person. How I can do it?
 
Hello, i have 11 digits number, example 37704252536. Its personal code and boldet&underlined digits are birth date. Me needs that I can from this numer to calculate age a person. How I can do it?







You will need to use a couple of Built-In Access Functions to accomplish what you want, although the outcome will depend on the input being exact to its expectations.
  1. Use cStr() to change the Number to a String unless it is already stored as a String.
  2. Use Mid() to extract the Sub-String that you want.
  3. Use cDate() combined with Format() to change the Sub-String to a date.
Look up the Functions and try them out. Get back with any additional questions.
 
Hi -

Assuming it's actually a number, here are steps to convert it to a date.
Then, you'll find numerous entries in this forum for computing age (need to know if you just need age in years, or years/months, etc..

Code:
x = 37704252536
? x
 37704252536 

y = mid(x,2,6)
? y
770425

z = dateserial(left(y,2), mid(y,3,2), right(y,2))
? z
4/25/1977

HTH - Bob
 
Thanks for answer. Very help me. Now I have birth date. Me needs age:)
 
Thanks for answer. Very help me. Now I have birth date. Me needs age:)

Try looking up the Date() function in VBA help. It will give you today's date.

Age can be calculated by subtracting DOB from Today's date.
 
Take a look here

HTH - Bob

-----

That link apparently doesn't want to work, so here's the full text I was pointing to:

Hi -

This function will allow you return age in years based on specified date, or the current date (see the 3rd example). In your query try creating a calculated field, e.g.

CurrAge: fage2([DOB]) then, in the criteria cell >= 18, or whatever age you want to include.


Code:
Function fAge2(DOB As Date, Optional dteEnd As Variant) As Integer
're: http://www.access-programmers.co.uk/forums/showthread.php?t=116432
'coded by: raskew
'Inputs:  1) ? fAge2(#4/13/53#, #10/23/06#)
'         2) ? fAge2(#11/1/53#, #10/23/06#)
'         3) ? fage2(#4/13/53#)
'Outputs: 1) 53
'         2) 52
'         3) 56

   dteEnd = IIf(IsMissing(dteEnd), Date, dteEnd)
   fAge2 = DateDiff("yyyy", DOB, dteEnd) + (DateSerial(year(dteEnd), month(DOB), day(DOB)) > dteEnd)

End Function

HTH - Bob
 
Last edited:

Users who are viewing this thread

Back
Top Bottom