GREL Date Functions - tfmorris/OpenRefine GitHub Wiki

Date functions supported by the OpenRefine Expression Language (GREL)

See also: All GREL functions.

now()

Returns the current time.

toDate(o, boolean month_first / format1, format2, ... )

Returns o converted to a date object.

All other arguments are optional:

  • month_first: set false if the date is formatted with the day before the month.
  • formatN: attempt to parse the date using an ordered list of possible formats. See SimpleDateFormat for the syntax.

Examples: You can parse the cells "Nov-09" and "11/09" using

value.toDate('MM/yy','MMM-yy').toString('yyyy-MM')

For a date of the form: "1/4/2012 13:30:00" use GREL function:

toDate(value,"dd/mm/YYYY H:m:s")

toString(o, optional string format)

When o is a date, format specifies how to format the date.

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

For dates, returns the difference in given time units.

See https://github.com/OpenRefine/OpenRefine/issues/624 for a discussion on a bug in dif() and its workaround.

inc(date d, number value, string unit)

Returns a date changed by the given amount in the given unit of time. Unit defaults to 'hour'.

datePart(date d, string unit)

Returns part of a date.

⚠️ **GitHub.com Fallback** ⚠️