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

StackOverflow https://stackoverflow.com/questions/23250341

  •  08-07-2023
  •  | 
  •  

سؤال

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!

هل كانت مفيدة؟

المحلول 2

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.

نصائح أخرى

Or use the select values step.. this can make copies of fields then you simply specify the format mask for the date to string conversion in the meta tab. Potentially more flexible too..

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top