Customer Portal

2 digit Date conversion

Comments 1

  • Avatar
    simaj
    0
    Comment actions Permalink
    Hi,

    As I understood, you would like to transform dates with two digit years to dates with four digits year format. This can be performed by the component Reformat. Below is an example of the transformation from the Reformat component that transforms dates from YY-MM-dd to YYYY-MM-dd format.

    The transformation function compares two digit years with the predefined variable "a" that sets the boundary between years that belong to the current and to the last century. In the case below is the number a = 5, which means that years 00 - 05 will be prefixed with 20 and anything above will get prefix 19.

    You can replace the "a" variable with a graph parameter to facilitate year adjustments.
    function


    integer a;
    a = 05;

    function integer transform() {

    if(str2integer(substring($in.0.Field1,0,2)) =< a){
    $out.0.Field1= "20"+substring($in.0.Field1,0,2)+chop($in.0.Field1, "^..");
    return 0;
    }
    else {
    $out.0.Field1="19"+substring($in.0.Field1,0,2)+chop($in.0.Field1, "^..");
    return 0;
    }
    }

    }


    I hope this will help you!

Please sign in to leave a comment.