> ## Documentation Index
> Fetch the complete documentation index at: https://new.docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# date.parse

> Parses a date/time string into a Date object using an optional format pattern.

## Description

Parses a date/time string into a Date object using an optional pattern. Supports explicit patterns and falls back to standard Date parsing for other formats.

## Syntax

```cypher theme={null}
flex.date.parse(dateString, pattern, timezone)
```

## Parameters

| Parameter    | Type   | Required | Description                                                                                                    |
| ------------ | ------ | -------- | -------------------------------------------------------------------------------------------------------------- |
| `dateString` | string | Yes      | The date/time string to parse                                                                                  |
| `pattern`    | string | No       | Format pattern (supported: `'YYYY-MM-DD'`, `'YYYY-MM-DDTHH:mm:ss'` or `'YYYY-MM-DD HH:mm:ss'`, or auto-detect) |
| `timezone`   | string | No       | Timezone offset like `"+02:00"` to interpret input in specific timezone                                        |

## Returns

**Type:** Date

A Date object representing the parsed date/time. Returns `null` if parsing fails.

## Examples

### Example 1: Parse Date Only

```cypher theme={null}
RETURN flex.date.parse('2024-03-15', 'YYYY-MM-DD') AS date
```

**Output:**

```text theme={null}
date
-----------------------------
2024-03-15T00:00:00.000Z (Date object)
```

### Example 2: Parse DateTime

```cypher theme={null}
RETURN flex.date.parse('2024-03-15T14:30:00', 'YYYY-MM-DDTHH:mm:ss') AS datetime
```

### Example 3: Auto-detect ISO Format

```cypher theme={null}
RETURN flex.date.parse('2024-03-15T14:30:00Z') AS dt
```

### Example 4: Parse with Timezone Context

```cypher theme={null}
WITH '2024-03-15 10:00:00' AS localTime
RETURN flex.date.parse(localTime, 'YYYY-MM-DDTHH:mm:ss', '+05:00') AS utcTime
```

(Interprets input as being in +05:00 timezone and converts to UTC)

### Example 5: Batch Import with Date Parsing

```cypher theme={null}
UNWIND $events AS event
CREATE (e:Event {
    name: event.name,
    date: flex.date.parse(event.dateString, 'YYYY-MM-DD')
})
```

## Notes

* Returns `null` for invalid or unparseable date strings
* Supported explicit patterns: `'YYYY-MM-DD'`, `'YYYY-MM-DDTHH:mm:ss'` and `'YYYY-MM-DD HH:mm:ss'` (both `T` and space separators are accepted)
* Falls back to JavaScript Date constructor for other formats (ISO8601, etc.)
* Timezone parameter interprets the input time as local time in that offset
* All dates are normalized to UTC internally

## See Also

* [date.format](/udfs/flex/date/format) - Format date to string
* [date.truncate](/udfs/flex/date/truncate) - Truncate date to specific unit
* [date.toTimeZone](/udfs/flex/date/toTimeZone) - Convert date to timezone

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="What does flex.date.parse return?">
    It returns a date/time value parsed from a string. You can optionally provide a format pattern to match the input string's structure.
  </Accordion>

  <Accordion title="What happens if the string cannot be parsed?">
    The function returns `null` if the input string does not match the expected or specified format.
  </Accordion>
</AccordionGroup>
