Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Calculate age as at January 1st !!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Calculate age as at January 1st !!!

    Let me try and explain this one !!!!

    My application needs to validate the "age" of a competitor to be eligible to enter a race class [category i.e. OR1].

    The age to enter the OR1 class is 16. However this is 16 years of age on the 1st of January. If the competitor is already/still 16 on the on the 1st of January, then he can enter the race.

    BUT !!!

    If he turned 17 BEFORE the 1st of January then he is not allowed to enter the race and if he turned 17 any other day of the year after the 1st of January, then he can still enter.

    MY question;
    How do I bring the 1st of January into the equation when his age is calculated and he enters TODAY [any date after the 1st of January].

    Confused, yip I am.

    16 years of age on the 1st of January is the marker/threshold. If he turns 17 on the 2nd of January then he can still enter the OR1 class as his entry age is calculated as on the 1st of January. Damn this is confusing.

    #2
    Re: Calculate age as at January 1st !!!

    hello

    the age function takes both arguments, date of birth and as of date.
    can you use that to calculate?
    for example this is done in the interactive window

    Code:
    dim date_of_birth as d
    dim on_the_day as d
    date_of_birth = {10/02/1949}
    on_the_day = {01/01/2013}
    ?age(date_of_birth)
    = 64
    
    ?age(date_of_birth,{01/01/2000})
    = 50
    
    
    ?age(date_of_birth,on_the_day)
    = 63
    Last edited by GGandhi; 11-28-2013, 06:19 PM.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    [email protected]
    Skype:[email protected]
    1 914 924 5171

    Comment


      #3
      Re: Calculate age as at January 1st !!!

      I think this is correct... have a look...

      http://www.youtube.com/watch?v=dJhwoR749o0

      You don't really need both these functions but here they are. Both functions take a parameter - the Date of Birth. The calculate_age does just that... calculates the age as of today. The calculate_age_as_of calculates the age as of a certain date... in this case Jan. 1 of the next year. I found the calcs on StackOverflow and adjusted a bit.

      Code:
      function calculate_age(currDOB)
      {
      
      	var dob = new Date(currDOB);
          var birth_year = dob.getFullYear();
          var birth_month = dob.getMonth();
          var birth_day = dob.getDate();
      
          var today_date = new Date();
          var today_year = today_date.getFullYear();
          var today_month = today_date.getMonth();
          var today_day = today_date.getDate();
          var age = today_year - birth_year;
      
          if ( today_month < (birth_month))
          {
              age--;
          }
          if (((birth_month) == today_month) && (today_day < birth_day))
          {
              age--;
          }
          return age;
      }
      Code:
      function calculate_age_as_of(currDOB)
      {
      
      	var dob = new Date(currDOB);
          var birth_year = dob.getFullYear();
          var birth_month = dob.getMonth();
          var birth_day = dob.getDate();
          
          var today_date = new Date();
          var today_year = today_date.getFullYear();
          today_year = today_year + 1;
          var today_month = 0; //remember this is zero based
          var today_day = 1;
          var age = today_year - birth_year;
      
          if ( today_month < (birth_month))
          {
              age--;
          }
          if (((birth_month) == today_month) && (today_day < birth_day))
          {
              age--;
          }
          return age;
      }
      The onClick events runs this code...

      Code:
      var currDOB = {dialog.Object}.getValue('currDOB');
      var currAge = calculate_age(currDOB);
      {dialog.Object}.setValue('currAge', currAge);
      
      
      var ageAsOf = calculate_age_as_of(currDOB);
      {dialog.Object}.setValue('ageAsOfNewYear', ageAsOf);

      Comment


        #4
        Re: Calculate age as at January 1st !!!

        other way around
        if you have a field date_of_birth onChange event can call a javascript that checks the eligibility by

        Code:
        if age(date_of_birth,ctod("1/1/"+year(date()))) > 16
        function_name = "alert('You are not eligible to enter the event!');"
        end if
        looks simple
        thanks for reading

        gandhi

        version 11 3381 - 4096
        mysql backend
        http://www.alphawebprogramming.blogspot.com
        [email protected]
        Skype:[email protected]
        1 914 924 5171

        Comment


          #5
          Re: Calculate age as at January 1st !!!

          Wow,

          Thanks for the feedback. There is light at the end of the tunnel [huge tunnel in my case]

          Below is the code I run on a radio button called 'CompAMClass1E'. This code runs on the client side immediate validation on a grid and it works great.
          The 'AgeN' field has the age in days calculated by code placed in the SQL 'age' field. Gandi, this is the same code you assisted me with a week or what ago and it works great.

          So, I have an ageN field with the age being displayed correctly. How do I coincide your code with this code below

          var rn = {grid.object}._selectedRow;

          var AgeN = {grid.object}.getValue('G','AGE',rn);
          var CompA = {grid.object}.getValue('G','COMPETITIONA',rn);
          var RaceType = {grid.object}.getValue('G','SENIORJUNIOR',rn);

          var SOR1MinAgeN = 16;

          var CompAMClass1 = {grid.object}.getValue('G','CompAMClass1',rn);

          if(CompA == 'Senior National' && CompAMClass1 == 'OR1' && CompAMClass1E == 'Yes')
          {
          if(AgeN < SOR1MinAgeN)
          {
          return 'Age must be older or equal to 16 for OR1 Class';
          }
          }
          return false;

          Comment


            #6
            Re: Calculate age as at January 1st !!!

            Oh, In my scenario above, I have the running age. I need to bring 1st of Jan into it as age by date

            Comment


              #7
              Re: Calculate age as at January 1st !!!

              hello
              if I look at your code
              AgeN is age in number of days
              SOR1MinAge age in numbers of years
              cannot be compared to give you what you want.
              if you look at your grid and how it is constructed you will see date of birth. if you do then

              var dateOFBirth = {grid.object}.getValue('G','DATE_OF_BIRTH',rn);
              if (age(dateOfBirth,ctod("1/1/"+year(date()))) < 16, "You must be older or equal to 16 for OR1 Class"," ")

              will probably work
              Last edited by GGandhi; 11-29-2013, 06:44 AM.
              thanks for reading

              gandhi

              version 11 3381 - 4096
              mysql backend
              http://www.alphawebprogramming.blogspot.com
              [email protected]
              Skype:[email protected]
              1 914 924 5171

              Comment


                #8
                Re: Calculate age as at January 1st !!!

                Hi Gandhi,

                I tried it as such, but validation does not take place.

                Could you perhaps explain to me what this all means so I can try and understand the function rather than just copy and paste it.
                This is how I changed it;

                var DOB = {grid.object}.getValue('G','DOB',rn);
                if (AgeN(DOB,ctod("1/1/"+year(date()))) < 16)

                Comment


                  #9
                  Re: Calculate age as at January 1st !!!

                  Sorry I submitted the response before I completed the above.

                  var DOB = {grid.object}.getValue('G','DOB',rn);

                  if (AgeN(DOB,ctod("1/1/"+year(date()))) < SOR1MinAgeN)
                  {
                  return 'Too Young for OR1 class'
                  }

                  Comment


                    #10
                    Re: Calculate age as at January 1st !!!

                    Sorry,

                    I changed AgeN to age as per your example, but it still does not validate.

                    Comment


                      #11
                      Re: Calculate age as at January 1st !!!

                      Hi Dave

                      I'm trying all the methods provided. Your video shows clearly what happens.

                      Question;
                      I have fields DOB & Age in my grid. Currently age is calculated from sql field formula [in sql].

                      Must I remove the sql formula and then use your function to calculate the age when the competitor clicks the radio button on "Yes"

                      I think my issue is, or rather I KNOW my issue is WHERE to run this function from and how to structure it for my client side immediate validation

                      Comment


                        #12
                        Re: Calculate age as at January 1st !!!

                        okay
                        would you mind posting a screeshot of the grid so as to know how it is constructed.
                        or
                        is this a form that competitor fills out with several races listed as check box and they click to enroll for various races?
                        and you want to validate when they check the checkboxes?
                        thanks for reading

                        gandhi

                        version 11 3381 - 4096
                        mysql backend
                        http://www.alphawebprogramming.blogspot.com
                        [email protected]
                        Skype:[email protected]
                        1 914 924 5171

                        Comment


                          #13
                          Re: Calculate age as at January 1st !!!

                          Nope Gandhi, its a "form" grid with the respective fields on the grid.

                          To choose the race classes the competitor needs to click a radio button "yes" or "no", no being the default value.

                          On clicking "yes" the immediate field validation runs. Everything works and the validations work great, however, I need to validate the age as at the 1st of January.

                          My current age field is calculated by the sql field formula (datediff(day,[DOB],getdate())/(365.25)) and is loaded as soon as the grid retrieves the info from the competitor table. This is correctly as you stated, age in days and not a date format.

                          Below is the full validation code for one of the buttons. You will see the age, DOB fields, however, i'm actually only using the age field for validation as sql already did that one. Every "age" validation i'll need to change to what this thread is about.

                          var rn = {grid.object}._selectedRow;

                          var AgeN = {grid.object}.getValue('G','AGE',rn);
                          var Sex = {grid.object}.getValue('G','SEX',rn);
                          var CompType = {grid.object}.getValue('G','COMPETITIONTYPE',rn);
                          var EventType = {grid.object}.getValue('G','EVENTTYPE',rn);
                          var CompA = {grid.object}.getValue('G','COMPETITIONA',rn);
                          var RaceType = {grid.object}.getValue('G','SENIORJUNIOR',rn);
                          var EngineSize = {grid.object}.getValue('G','ENGINCAPACITY',rn);

                          var SNMCMinAgeN = 16;
                          var SNMSenMinAgeN = 38;
                          var SNMMasMinAgeN = 46;
                          var SNMSCMaxAgeN = 18;
                          var JNMOpenMinAgeN = 15;
                          var JNMOpenMaxAgeN = 17;
                          var JNM125MinAgeN = 13;
                          var JNM125MaxAgeN = 17;
                          var JNMSen85MinAgeN = 13;
                          var JNMSen85MaxAgeN = 15;
                          var JNMJun85MinAgeN = 8;
                          var JNMJun85MaxAgeN = 12;
                          var JNM65MinAgeN = 7;
                          var JNM65MaxAgeN = 11;
                          var SOR1MinAgeN = 18;
                          var SOR3MinAgeN = 16;
                          var SOR2MinAgeN = 18;
                          var SHighMinAgeN = 14;
                          var SHighMaxAgeN = 16;

                          var CompAMClass1 = {grid.object}.getValue('G','CompAMClass1',rn);
                          var CompAMClass2 = {grid.object}.getValue('G','CompAMClass2',rn);
                          var CompAMClass3 = {grid.object}.getValue('G','CompAMClass3',rn);
                          var CompAMClass4 = {grid.object}.getValue('G','CompAMClass4',rn);
                          var CompAMClass5 = {grid.object}.getValue('G','CompAMClass5',rn);
                          var CompAMClass6 = {grid.object}.getValue('G','CompAMClass6',rn);
                          var CompAMClass7 = {grid.object}.getValue('G','CompAMClass7',rn);
                          var CompAMClass8 = {grid.object}.getValue('G','CompAMClass8',rn);
                          var CompAMClass1E = {grid.object}.getValue('G','CompAMClass1E',rn);
                          var CompAMClass2E = {grid.object}.getValue('G','CompAMClass2E',rn);
                          var CompAMClass3E = {grid.object}.getValue('G','CompAMClass3E',rn);
                          var CompAMClass4E = {grid.object}.getValue('G','CompAMClass4E',rn);
                          var CompAMClass5E = {grid.object}.getValue('G','CompAMClass5E',rn);
                          var CompAMClass6E = {grid.object}.getValue('G','CompAMClass6E',rn);
                          var CompAMClass7E = {grid.object}.getValue('G','CompAMClass7E',rn);
                          var CompAMClass8E = {grid.object}.getValue('G','CompAMClass8E',rn);

                          /* CompAMClass1 validation */
                          if(CompA == 'Senior Club')
                          {
                          if(AgeN < SHighMinAgeN)
                          {
                          return 'Your Age is below the required Limit for a Senior Club Event !!!';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'OR1' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < SOR1MinAgeN)
                          {
                          return 'Age must be older or equal to 18 for OR1 Class';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'OR1' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Bigger Than 251cc, 2-Stroke' && EngineSize != 'Bigger Than 401cc, 4-Stroke' && EngineSize != 'Bigger Than 201cc, 2-Stroke' && EngineSize !=
                          'Smaller Than 251cc, 2-Stroke' && EngineSize != 'Smaller Than 201cc, 2-Stroke' && EngineSize != 'Smaller Than 251cc, 4-Stroke')
                          {
                          return 'Engine Size must be Bigger Than 200cc, 2-Stroke OR Bigger Than 250cc, 4-Stroke';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'OR2' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < SOR2MinAgeN)
                          {
                          return 'Age must be older or equal to 18 for OR2 Class';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'OR2' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Bigger Than 201cc, 2-Stroke' && EngineSize != 'Smaller Than 251cc, 2-Stroke' && EngineSize != 'Smaller Than 201cc, 2-Stroke' && EngineSize !=
                          'Smaller Than 251cc, 4-Stroke' && EngineSize != 'Bigger Than 251cc, 4-Stroke')
                          {
                          return 'Engine Size must be Up to 250cc, 2-Stroke and 400cc, 4-Stroke';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'OR3' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < SOR3MinAgeN)
                          {
                          return 'Age must be older or equal to 16 for OR3 Class';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'OR3' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Smaller Than 201cc, 2-Stroke' && EngineSize != 'Smaller Than 251cc, 4-Stroke')
                          {
                          return 'Engine Size must be Up to 200cc, 2-Stroke and 250cc, 4-Stroke';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'Senior' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < SNMSenMinAgeN)
                          {
                          return 'Age must be older or equal to 38 for Senior Class';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'HighSchool' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < SHighMinAgeN || AgeN > SHighMaxAgeN)
                          {
                          return 'Age must be between 14 & 16 for Highschool Class';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'HighSchool' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Smaller Than 201cc, 2-Stroke' && EngineSize != 'Smaller Than 251cc, 4-Stroke')
                          {
                          return 'Engine Size must be Smaller Than 201cc, 2-Stroke OR Smaller Than 251cc, 4-Stroke';
                          }
                          }

                          if(CompA == 'Senior Club' && CompAMClass1 == 'Master' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < SNMMasMinAgeN)
                          {
                          return 'Age must be older or equal to 46 for Master Class';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'Silver' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < SNMSCMinAgeN && AgeN > SNMSCMaxAgeN)
                          {
                          return 'Age must be between than 16 and 18 for Silver class';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'Silver' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Smaller Than 201cc, 2-Stroke' && EngineSize != 'Smaller Than 251cc, 4-Stroke')
                          {
                          return 'Engine Size must be Smaller Than 201cc, 2-Stroke OR Smaller Than 251cc, 4-Stroke';
                          }
                          }
                          if(CompA == 'Senior Club' && CompAMClass1 == 'Ladies' && CompAMClass1E == 'Yes')
                          {
                          if(Sex != 'Female')
                          {
                          return 'Only Ladies can enter this class';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == 'Open' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < JNMOpenMinAgeN || AgeN > JNMOpenMaxAgeN)
                          {
                          return 'Junior Open Class Age must be between 15 & 17';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == 'Open' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Smaller Than 201cc, 2-Stroke' && EngineSize != 'Smaller Than 251cc, 4-Stroke')
                          {
                          return 'Engine Size must be Smaller than 201cc 2-Stroke OR Smaller Than 251cc 4-Stroke';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == '125cc' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < JNM125MinAgeN || AgeN > JNM125MaxAgeN)
                          {
                          return 'Junior Open Class Age must be between 13 & 17';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == '125cc' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Smaller Than 126cc, 2-Stroke')
                          {
                          return 'Engine Size must be Smaller Than 126cc, 2-Stroke';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == 'Senior 85' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < JNMSen85MinAgeN || AgeN > JNMSen85MaxAgeN)
                          {
                          return 'Junior Open Class Age must be between 13 & 15';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == 'Senior 85' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Smaller Than 106cc, 2-Stroke' && EngineSize != 'Smaller Than 151cc, 4-Stroke')
                          {
                          return 'Engine Size must be Smaller Than 106cc, 2-Stroke OR Smaller Than 151cc, 4-Stroke';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == 'Junior 85' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < JNMJun85MinAgeN || AgeN > JNMJun85MaxAgeN)
                          {
                          return 'Junior Open Class Age must be between 8 & 12';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == 'Junior 85' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Smaller Than 106cc, 2-Stroke' && EngineSize != 'Smaller Than 151cc, 4-Stroke')
                          {
                          return 'Engine Size must be Smaller Than 106cc, 2-Stroke OR Smaller Than 151cc, 4-Stroke';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == 'Junior 65' && CompAMClass1E == 'Yes')
                          {
                          if(AgeN < JNM65MinAgeN || AgeN > JNM65MaxAgeN)
                          {
                          return 'Junior Open Class Age must be between 7 & 11';
                          }
                          }
                          if(CompA == 'Junior Club' && CompAMClass1 == 'Junior 65' && CompAMClass1E == 'Yes')
                          {
                          if(EngineSize != 'Smaller Than 66cc, 2-Stroke' && EngineSize != 'Smaller Than 81cc, 4-Stroke')
                          {
                          return 'Engine Size must be Smaller Than 66cc, 2-Stroke OR Smaller Than 81cc, 4-Stroke';
                          }
                          }
                          return false;

                          Comment


                            #14
                            Re: Calculate age as at January 1st !!!

                            var AgeN = {grid.object}.getValue('G','AGE',rn);
                            var Sex = {grid.object}.getValue('G','SEX',rn);
                            var CompType = {grid.object}.getValue('G','COMPETITIONTYPE',rn);
                            var EventType = {grid.object}.getValue('G','EVENTTYPE',rn);
                            var CompA = {grid.object}.getValue('G','COMPETITIONA',rn);
                            var RaceType = {grid.object}.getValue('G','SENIORJUNIOR',rn);
                            var EngineSize = {grid.object}.getValue('G','ENGINCAPACITY',rn);
                            I do not see date_of_birth
                            do you have date of birth in the grid? ( I know you have age)
                            if you have date_of_birth in the grid then try the following
                            dim Date_Of_Brith = {grid.object}.getValue('G','DATE_OF_BIRTH',rn)
                            dim AgeN as n
                            AgeN = age(Date_Of_Birth, ctod("01/01/"+year(date())))
                            then keep the rest of your code and see if it works.
                            I am only changing how AgeN is calculated.
                            Last edited by GGandhi; 12-03-2013, 09:31 AM.
                            thanks for reading

                            gandhi

                            version 11 3381 - 4096
                            mysql backend
                            http://www.alphawebprogramming.blogspot.com
                            [email protected]
                            Skype:[email protected]
                            1 914 924 5171

                            Comment


                              #15
                              Re: Calculate age as at January 1st !!!

                              Do I insert this code also with the above?

                              Comment

                              Working...
                              X