Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Go back in time for Spoon

  1. #1
    Join Date
    Oct 2016
    Posts
    3

    Post Go back in time for Spoon

    Hello guys,

    I need inside a Spoon transformation to "go back in time" of 11 months on a date object in the following format


    YYYYMM


    For example, if the date is valid 201611 I would like the system I would calculate the date 11 months before or that I would restore 201510.


    There is an object or one that can JavaScript scripts already used in Spoon You?
    Many thanks

    Corpie

  2. #2
    Join Date
    Apr 2008
    Posts
    1,771

    Default

    You can use calculator step.
    -- Mick --

  3. #3
    Join Date
    Oct 2016
    Posts
    3

    Default

    Quote Originally Posted by Mick_data View Post
    You can use calculator step.
    I used a JavaScript script here is as follows

    var today = new Date();
    today = dateAdd(today, "m", -11);

    Thanks

  4. #4
    Join Date
    Apr 2008
    Posts
    1,771

    Default

    Hi.
    Yes, you can use javascript but the point of PDI is to do the same using Steps, so that someone who does not underatsnd java (like me!) can understand what's going on.
    -- Mick --

  5. #5
    Join Date
    Nov 2009
    Posts
    688

    Default

    An other point is that the javascript step is slower then the calculator step.

  6. #6
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Sadly, Kettle beginners don't understand the importance of not using procedural logic (like JavaScript) if avoidable.
    Attached Files Attached Files
    So long, and thanks for all the fish.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.