Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2012
    Posts
    87

    Lightbulb Unanswered: Generate DOB and Age from ID

    Hi

    I have 3 fields: ID, DOB (Date of Birth) and Age

    When I enter the ID I want the DB to automatically show the DOB and Age in the DOB and Age fields.

    The format of the id is: 70031400989 70 is the year, 03 is the month and 14 is the day. 14-03-1970

    It must look like this:

    ID: 70031400989 (enter manually)
    DOB: 14-03-1970 (Display automatic after ID was entered)
    Age: 46 (Display automatic after ID was entered)

    Hope someone can help me with this.

    Hennie


    The ID will always consists of 11 characters.

  2. #2
    Join Date
    Mar 2016
    Location
    Netherlands
    Posts
    4
    Hi Hennie,

    This is the code for AGE.

    Execute field's script (NAME OF FORM: DOB, On edit)
    NAME OF FORM: [AGE] = dateDiff(dateCurrent(),[DOB],|Year|) – If (datePart([DOB],|Month|)*32 + datePart([DOB],|Day|),|more|,datePart(dateCurrent(),|Month|)*32 + datePart(dateCurrent(),|Day|))

    BOLD = your form name and field name. 2nd line of code use Action Set field value math (or text)

    Jerry
    Last edited by jzahour; 03-17-16 at 09:50.

  3. #3
    Join Date
    Mar 2016
    Location
    Netherlands
    Posts
    4
    Hi Hennie,

    This is the code for DOB. But it works only if the DOB field is a TEXT field. The ID field can be a numeric field.

    Execute field's script (NAME OF FORM: IDFIELD, On edit)
    (NAME OF FORM: DOB = "[IDFIELD^text SYMB4;][IDFIELD^text SYMB5;]-[IDFIELD^text SYMB2;]IDFIELD^text SYMB3;]-19[IDFIELD^text SYMB0;][IDFIELD^text SYMB1;]"

    For the 2nd line of code use the Action Set Field Value Text. One problem still left : to distinguish the year 1900 and 2000. I think the easiest way is to extend your IDField with 2 characters for 19 en 20.
    Your IDField should read 1970031400989 or 2070031400989

    Jerry
    Last edited by jzahour; 03-17-16 at 10:39.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •