Skip to Content
author's profile photo Former Member
Former Member

Adding Year

Hello everybody,

Could anybody tell me how do i add the year to the existing one.

Suppose if i have 1911(YYYY) i have to add 95(YY) so that i get 2006(YYYY).

1911(YYYY) + 95(YY) = 2006(YYYY)

Is there any way we can achieve this.

Thanks,

Chinna

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 03:56 AM

    hi chinna,

    this can be done easily using standard functions.

    Suppose only year is coming, then you can use add function to obtain the required modified year.

    YYYY

    [add] -


    New YYYY

    (10) /

    Suppose if you want modify the year in the date field, then you need to extract the year and then add the required additional year.

    You can achieve this by using DateTrans function to extract year and then add the required number to modify the year.

    Date -


    DateTrans(YYYY)

    -


    [add] -


    RequiredDate

    (10) /

    regards

    Ramesh P

    Message was edited by:

    Ramesh P

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 05:28 AM

    hi chinna,

    you can use <b>date transformation option</b> inesage mapping.

    it has all the option and you can add your options also.

    hope this will help

    regards

    HONEY

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2007 at 01:10 AM

    Hi Ramesh,

    I cannot extract the year using the datetrans . Could you pls give me more information on that function.

    Thanks,

    Chinna

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi chinna,

      You can extract only year out of date by using datetrans function, right click on the function, in the properties instead of MM/DD/YYYY you give only YYYY and then you get only year. I have already tried out and it works fine.

      Date --> DateTrans(YYYY) ---> Year

      After extracting the year you can add value to it

      regards

      ramesh p

  • Posted on Nov 23, 2007 at 04:56 AM

    Hi,

    If the value to be added is constant.

    Then using Standard function Date->DateTrans get the year and using user defined function add both then pass the result to output.

    Regards,

    Sakthi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2007 at 07:13 AM

    Hi

    Apart from using graphical mapping, you can go the udf also

    public void addToDate(String date, String years, Container c, Result result){

    String DATE_FORMAT = "dd-MM-yyyy";

    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);

    try

    {

    sdf.parse(date);

    } catch (ParseException e)

    {

    e.printStackTrace();

    }

    Calendar c1=sdf.getCalendar();

    int y=Integer.parseInt(years);

    c1.add(Calendar.YEAR,y);

    result.add(sdf.format(c1.getTime());

    }

    This gives the complete date after adding the years.You can modify it if you want something else.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.