Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Javascript for Splitting the Date field

  1. #1

    Default Javascript for Splitting the Date field

    Hi all,

    I need to split date which is in the format "7/12/2013" and get output as 2013-12-07.

    I used the below code which works perfectly fine on JS editor but the Pentaho output I get "NAN" in few places like 2013-NaN-12 or 2013-nan-nan and such

    //var Opt_In_Date = "7/12/2013";
    var datestring = Opt_In_Date.split("/");
    var dt1 = datestring[0];
    var mon1 = datestring[1];
    var yr1 = datestring[2];
    if(dt1<10){dt1 = '0'+dt1};
    if(mon1<10){mon1 = '0'+mon1};
    var DATE_OF_ACTIVITY1 = yr1+ '-'+ mon1 + '-' +dt1;
    //document.write(DATE_OF_ACTIVITY1);


    Appreciate any help!!!

    Thanks!!

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

    Default

    Quote Originally Posted by binewbieswede View Post
    I need to split date which is in the format "7/12/2013" and get output as 2013-12-07.
    Scripting, especially JavaScript, is kind of a last resort in Kettle.
    Usually, we use a Select Values step to reformat a date value.
    Attached Files Attached Files
    So long, and thanks for all the fish.

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.