Forum Discussion

vikaspasula's avatar
vikaspasula
Qrew Member
9 months ago

Re:age validation

please help me in creating a formula text field that checks whether the candidate is 18yrs or older  based on the dob field



------------------------------
vikas pasula
------------------------------
  • np,

    Here is the formula for a formula checkbox field.

    var date DOB = [DOB]; // put in your Date of Birth field here

    var number Age = Year(Today())-Year($DOB)
    -
    If(
    Month(Today())<Month($DOB)
    or
    (Month(Today())=Month($DOB) and Day(Today())<Day($DOB)),1,0);

    $Age >= 18



    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------
    • vikaspasula's avatar
      vikaspasula
      Qrew Member

      can you please check whether the below formula text field correct:

      If(Year(Today()) - Year(DOB - If(Today()<Date(Year(Today()),Month(DOB), Day(DOB)), 1, 0)>=18,"older ", "less than 18 years old")



      ------------------------------
      vikas pasula
      ------------------------------
    • vikaspasula's avatar
      vikaspasula
      Qrew Member

      can you please check whether the below formula text field correct:

      If(Year(Today()) - Year(DOB) - If(Today()<Date(Year(Today()),Month(DOB), Day(DOB)), 1, 0)>=18,"older ", "less than 18 years old")



      ------------------------------
      vikas pasula
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend

        I suggest that you test your formula with various states and if it tests OK then it's probably OK.  Note that you just have to enter a date into a date field, you don't have to actually save the record.  Just tab out of the field and you will see the results immediately



        ------------------------------
        Mark Shnier (Your Quickbase Coach)
        mark.shnier@gmail.com
        ------------------------------
  • DwightMunson1's avatar
    DwightMunson1
    Qrew Assistant Captain

    I use this formula to get the employee's current anniversary year. 

    Floor(ToDays(Today()-[Sigma Employment Date])/365.25)

    ----------------------------------------------------------------

    var date DOB = [Your Date of Birth Field];

    var number Age = Floor(ToDays(Today()-$DOB/365.25);

    If(

    $Age >= 18, "older",

    "less than 18 years old"

    )



    ------------------------------
    Dwight Munson
    ------------------------------