Hitachi Vantara Pentaho Community Forums
Results 1 to 7 of 7

Thread: Get Day in Javascript Step

  1. #1

    Default Get Day in Javascript Step

    Hello,

    I have to get the day of a date in field DATE_OF_ORIGINATION. I am using the modified "Modified Java Script Value" step. I have been able to use the "year" and "month" functions but I am not able to make the getDate function of Javascript to work.

    Can anyone help me in understanding how to get the day of a date in a field by using this step?

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

    Default

    You forgot to show us the JavaScript code you tried to extract the day of a month.
    So long, and thanks for all the fish.

  3. #3

    Default

    Quote Originally Posted by perito37 View Post
    Hello,

    I have to get the day of a date in field DATE_OF_ORIGINATION. I am using the modified "Modified Java Script Value" step. I have been able to use the "year" and "month" functions but I am not able to make the getDate function of Javascript to work.

    Can anyone help me in understanding how to get the day of a date in a field by using this step?
    Hello,

    this is my code:

    var object_date= new Date(fecha);
    var year_number=year(fecha);
    var month_number=month(fecha);
    var day_number=object_date.getDate();

    fecha is a field with a date value

    When I run the script it seems like the Date object I create (object_date), does not take any value. And when I apply the method getDate(), it does not return anything.

  4. #4
    Join Date
    May 2014
    Posts
    358

    Default

    Do you absolutely have to use the Java script step? The Calculator step can easily extract day of month or day of year from a date.

  5. #5

    Default

    Quote Originally Posted by Lukfi View Post
    Do you absolutely have to use the Java script step? The Calculator step can easily extract day of month or day of year from a date.
    The thing is that I need to do many calculations with dates and I think it is better to have this in an unique step. I think there must be some way to do this in Javascript but I do not know how to do so.

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

    Default

    Try this way:

    Code:
    var year_number = year(fecha);
    var month_number = 1 + month(fecha);
    var day_number = fecha.getDate();
    So long, and thanks for all the fish.

  7. #7

    Default

    Quote Originally Posted by marabu View Post
    Try this way:

    Code:
    var year_number = year(fecha);
    var month_number = 1 + month(fecha);
    var day_number = fecha.getDate();
    Now it works. thank you very much

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.