apoc.date.convertFormat

Function APOC Core

apoc.date.convertFormat('Tue, 14 May 2019 14:52:06 -0400', 'rfc_1123_date_time', 'iso_date_time') - convert a String of one date format into a String of another date format.

Signature

apoc.date.convertFormat(temporal :: STRING?, currentFormat :: STRING?, convertTo = yyyy-MM-dd :: STRING?) :: (STRING?)

Input parameters

Name Type Default

temporal

STRING?

null

currentFormat

STRING?

null

convertTo

STRING?

yyyy-MM-dd

Usage Examples

The currentFormat parameter supports the values specified under Patterns for Formatting and Parsing for the DateTimeFormatter.

The convertTo parameter supports Java formats or built-in formats.

The following converts a date in YYYY-MM-dd format to basic_date (yyyyMMdd) format:

RETURN apoc.date.convertFormat("2020-11-04", "date", "basic_date") AS output;
Table 1. Results
output

"20201104"

The following converts a date in date_hour (yyyy-MM-dd’T’HH) format to date_hour_minute (yyyy-MM-dd’T’HH:mm) format:

RETURN apoc.date.convertFormat("2020-11-04T22", "date_hour", "date_hour_minute") AS output;
Table 2. Results
output

"2020-11-04T22:00"