Extracting Year And Month From A Date Value Using Pentaho Kettle
This blog is dedicated to the need of extracting year and month value from a particular date column with a default yyyy/mm/dd HH:mm:ss format.For that we’ll make use of mainly the calculator step in Pentaho to extract the given month and year for that particular date.This calculator step provides you with predefined functions that can be executed on input field values.
In the screenshot below we have two date columns namely order_date and ship_date which are the input date columns for this particular task.
In the next step we take a calculator step where we’ve defined the calculation type as select Year of Date and select month of Date as shown in the above snapshot.
We also defined the name of the new fields which will contain the individual year and month values for each order_date value and ship_date value.Besides the arguments (Field A, Field B or Field C) you must also specify the return type of the function.
Finally when we run the transformation we’ll have additional columns as shown below , which gives us the required year and month columns namely order_month,shipment_year,order_month and shipment_month.