apoc.date.convertFormat

Details

Syntax

apoc.date.convertFormat(temporal, currentFormat [, convertTo ])

Description

Converts a STRING of one type of date format into a STRING of another type of date format.

Arguments

Name

Type

Description

temporal

STRING

A string representation of a temporal value.

currentFormat

STRING

The format the given temporal is formatted as.

convertTo

STRING

The format to convert the given temporal value to. The default is: yyyy-MM-dd.

Returns

STRING

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;
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;
Results
output

"2020-11-04T22:00"