Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to convert String data type into Date data type in pentaho

I have a string which has a date in this format: n_date=2014-04-20

I want to convert it into date data type

var Final_date = str2date(n_date,"yyyy-MM-dd");

but I get an error.

I'm do this in pentaho

like image 335
Mudi Avatar asked Mar 16 '23 06:03

Mudi


1 Answers

You don't need a Java script step to do that. It's much easier and faster to use a calculator step or a select values step instead:

1) Calculator step: Create a new field, Final_date as a Copy of field A; on Field A put the name of your input string; Data type is date and on Conversion mask choose the yyyy-MM-dd format (you don't have to pick one from the dropdown menu, you can write your own);

2) Select values: on the Metadata panel, choose your input field and Date as the data type; as above, fill in the date format your data comes in.

The difference between 1) and 2) is that in the 1st case you get a new field of the Date type, whereas in the 2nd case you change the data type of the input field.

like image 102
nsousa Avatar answered Apr 08 '23 22:04

nsousa