Search code examples
pentahoolapkettle

How to convert a date to string then split it into 4 parts using Pentaho Kettle


I have a table that contains a column named time_created representing a date: 2014-02-19 23:49:59.998557. Now I need to generate a new table that consists of year, month, day and quarter columns.(For analysis purpose).

For example, 2014-02-19 23:49:59.998557 should be converted to:

year| month | day | quarter

2014 | 2 | 19 | Q1

How can I do that using Kettle? Thanks!


Solution

  • Use a calculator step to generate the four fields you need (year, month,..). For each field use your timestamp as Field A and choose the appropriate calculation (e.g. Year of date A). You will need to work around the quarter field to prepend a Q (calculation = set field to constant value A ). You can do this in the same calculator step, using the remove feature to get rid of your Q field.