4 Replies Latest reply on Feb 19, 2016 1:00 AM by MAKALENG

    calculating date of birth

    MAKALENG

      i have two fields in 1 table

      the first field is ID NUMBER WITH 13 DIGITS

      and the second field is date of birth

      like ID NUMBER 8204116767081

      date of birth must be 1982-05-11

      first two number on id is year of birth second two is month and third two is date of birth

      can someone please help

        • 1. Re: calculating date of birth
          Extensitech

          getasdate (

            middle ( id number ; 3 ; 2 )

            & "/"

            & middle ( id number ; 5 ; 2 )

            & "/"

            & middle ( id number ; 1 ; 2 )

          )

           

          Like that?

           

          I can help but notice that the id number in your example would be 1982-04-11, but I assume this is just a typo?

           

          Chris Cain

          Extensitech

          • 2. Re: calculating date of birth
            DavidJondreau

            Your example is a little confusing. Shouldn't the birth day be 1982-04-11? Also, we do run into a little bit of a problem confusing centarians and young children. If a year is 15, should we assume that's 2015 or 1915? Something to think about.

             

            Let's take out 100 year olds and we get this:

             

            Let( [

            today = Get ( CurrentDate ) ;

            ID = GetAsText ( table::ID NUMBER ) ;

             

            y.tens =  (  Left ( ID ; 2 ) );

            y = GetAsNumber ( "20" & y.tens ) ;

            m = Middle ( ID ; 3 ; 2 ) ;

            d = Middle ( ID ; 5 ; 2 ) ;

             

            this.cent.result =  Date ( m ; d ; y ) ;

            last.cent.result = Date ( m ; d ; y - 100 ) ;

            result = If ( this.cent.result < today ; this.cent.result ; last.cent.result )

            ];

            result

            )

             

            *The formatting for the date is up to you to set in the field display options.

            • 3. Re: calculating date of birth
              MAKALENG

              thank! Ya it was typing error it was meant to be 04 not 05, this is how South Africa gives I'd number, will check if is working

              • 4. Re: calculating date of birth
                MAKALENG

                Thanks Extensitech & DavidJondreau i got masterpiece, i have set the answer to be date and for 15... is answering 2015, will just make it editable in an unlikely event i get 1915 clients