Subtracting dates with the Calculator step

Let's look at an example to demonstrate how to apply a date operation with the Calculator step. In this case, we have a list of dates. For each date, we want the matching date to be a week before, that is, our date minus seven days.

If you explore the Calculator options, there is no function to subtract dates, but there is one to add dates. So, the trick is to add a negative number. Let's proceed:

  1. Create a new Transformation and add a Data Grid step.
  2. Use the Data Grid to define a new field of Date type and populate the grid with some random values.
Alternatively, you can reuse one of the Date Range samples created in previous chapters.
  1. After the Data Grid, add a Calculator step. We will use it ...

Get Learning Pentaho Data Integration 8 CE - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.