Reputation: 151
How to Change the date format yyyy/MM/dd HH:mm:ss to dd_mm_yy through modified java script value in pentaho?
Upvotes: 1
Views: 16381
Reputation: 419
You can use the SELECT step, and then in the Meta Data Tab, you can select the datatype as DATE and then use the format as "dd_MM_yy"
That's it, pretty simple :)
Upvotes: 2
Reputation: 1764
Use this function in Modified Java Script Value
step:
date2str(input, "dd_MM_yy");
Upvotes: 3
Reputation: 41
In pentaho a Date has always the time. There is not such thing as only date.
So, my guess would be that you need to format on output, converting it to a string for example.
But, if what you need is the date without the time, and by this i mean "yyyy/mm/dd 00:00:00", you can get it like this in Javascript:
var dateFieldValue=<yourdatecolumn>;
var year = dateFieldValue.getYear()+1900;
var month = dateFieldValue.getMonth();
var day = dateFieldValue.getDate();
var dateOnly = new Date(year,month,day);
or the last line could be:
var dateOnly = year + '-' + (month+1) + '-' + day;
if you want a String output like 'yyyy-mm-dd'
Hope this helps.
Upvotes: 1