Search code examples
datediffdata-cleaningopenrefinegrel

Looking for a way to calculate time lapse in openrefine


This is the given expression of GREL language on OpenRefine.

diff(date d1, date d2, optional string timeUnit)

For dates, returns the difference in given time units.

So the question is how to get the access to the values of both columns, that is not clear on presented on the documentation.

Thanks


Solution

  • The formula for accessing another column is:

    cells.YourColumnName.value
    

    If your column name contains spaces or non-ascii characters :

    cells['Your Column Name'].value
    

    So, assuming your two columns are named "date1" and "date2", and you want the difference in days, the GREL formula is as follows :

    diff(cells.date1.value, cells.date2.value, "days")
    

    or

    diff(cells['date1'].value, cells['date2'].value, "days")