UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • GQL vs Other Languages
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Questioned Paths
    • Shortest Paths
    • Cheapest Paths
    • K-Hop Traversal
    • Graph Patterns
    • Overview
    • Open Graphs
    • Closed Graphs
    • Graph Types
    • Constraints
    • Projections
    • Storage Maintenance
    • Node and Edge IDs
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • MERGE
    • SET
    • REMOVE
    • DELETE
    • FOREACH
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Element Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Null Functions
    • Utility Functions
    • Type Conversion Functions
    • Table Functions
    • Database Functions
  • Operators
  • Predicates
    • CASE
    • LET Value Expression
    • Value Query Expression
    • List Expressions
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
  • Query Management
  • Execution Plan
  • Backup and Restore
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Naming Conventions
    • Syntactic Notation
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Functions

Datetime Functions

Datetime Value Functions

A datetime value function creates a temporal instant or duration value. Refer to Values and Types for date and time string formats.

date()

Creates a value of type DATE (LOCAL DATE).

Syntaxdate([<param>])
ArgumentsNameTypeDescription
<param>STRING, RECORD, or 3 INTsA date string, a record with year/month/day fields, or three integers (year, month, day)
Return TypeDATE
GQL
// returns the current local date, date() is equivalent to CURRENT_DATE
RETURN date(), CURRENT_DATE
GQL
RETURN date("1993-05-09"),
       date("1993-5-9"),
       date("19930509"),
       date("1993/05/09"),
       date("1993/5/9"),
       date({year: 1993, month: 5, day: 9}),
       date(1993, 5, 9)

local_time()

Creates a value of type LOCAL TIME. time() is a synonym.

Syntaxlocal_time([<param>])
ArgumentsNameTypeDescription
<param>STRING or RECORDA time string or a record with hour/minute/second fields and optionally millisecond, microsecond, or nanosecond
Return TypeLOCAL TIME
GQL
// returns the current local time, local_time() is equivalent to LOCAL_TIME
RETURN local_time(), LOCAL_TIME
GQL
RETURN local_time("03:02:11.700000000"),
       local_time("03:02:11"),
       local_time("03:02"),
       local_time("030211"),
       local_time("030211.700000000"),
       local_time({hour: 3, minute: 2, second: 11}),
       local_time({hour: 3, minute: 2, second: 11, millisecond: 700}),
       local_time({hour: 3, minute: 2, second: 11, microsecond: 700}),
       local_time({hour: 3, minute: 2, second: 11, nanosecond: 700})

local_datetime()

Creates a value of type LOCAL DATETIME.

Syntaxlocal_datetime([<param>])
ArgumentsNameTypeDescription
<param>STRING or RECORDA datetime string or a record with year/month/day/hour/minute/second fields and optionally millisecond, microsecond, or nanosecond
Return TypeLOCAL DATETIME
GQL
// returns the current local datetime, local_datetime() is equivalent to LOCAL_TIMESTAMP
RETURN local_datetime(), LOCAL_TIMESTAMP
GQL
RETURN local_datetime("1993-05-09T03:02:11.70"),
       local_datetime("1993-05-09 03:02:11"),
       local_datetime("1993/05/09 03:02:11"),
       local_datetime("1993/5/9 03:02:11"),
       local_datetime("19930509T030211"),
       local_datetime("19930509 030211"),
       local_datetime({year: 1993, month: 5, day: 9, hour: 3, minute: 2, second: 11}),
       local_datetime({year: 1993, month: 5, day: 9, hour: 3, minute: 2, second: 11, millisecond: 700}),
       local_datetime({year: 1993, month: 5, day: 9, hour: 3, minute: 2, second: 11, microsecond: 700}),
       local_datetime({year: 1993, month: 5, day: 9, hour: 3, minute: 2, second: 11, nanosecond: 700})

zoned_time()

Creates a value of type ZONED TIME.

Syntaxzoned_time([<param> [, <timezone>]])
ArgumentsNameTypeDescription
[<param>]STRING, RECORD, or TIMEA time string with timezone, a record with hour/minute/second/timezone fields and optionally millisecond, microsecond, or nanosecond
<timezone>STRINGTarget timezone offset (e.g., "+05:30", "Z") used to convert the first argument to a different timezone
Return TypeZONED TIME
GQL
// returns the current local zoned time, zoned_time() is equivalent to CURRENT_TIME
RETURN zoned_time(), CURRENT_TIME
GQL
RETURN zoned_time("12:20:02+08:00"),
       zoned_time("12:20:02Z"),
       zoned_time({hour: 12, minute: 20, second: 2, timezone: "+08:00"}),
       zoned_time({hour: 12, minute: 20, second: 2, timezone: "+08:00", millisecond: 500}),
       zoned_time({hour: 12, minute: 20, second: 2, timezone: "-06:00", microsecond: 700}),
       zoned_time({hour: 12, minute: 20, second: 2, timezone: "Z", nanosecond: 700})

Convert an existing time to a different timezone:

GQL
RETURN zoned_time("12:20:02+08:00", "+05:30")

zoned_datetime()

Creates a value of type ZONED DATETIME.

Syntaxzoned_datetime(<param> [, <timezone>])
ArgumentsNameTypeDescription
<param>STRING, RECORD, TIMESTAMP, or ZONED DATETIMEA datetime string with timezone, a record with year/month/day/hour/minute/second/timezone fields and optionally millisecond, microsecond, or nanosecond
<timezone>STRINGTarget timezone offset (e.g., "+05:30", "Z") used to convert the first argument to a different timezone
Return TypeZONED DATETIME
GQL
// returns the current local datetime, zoned_datetime() is equivalent to CURRENT_TIMESTAMP
RETURN zoned_datetime(), CURRENT_TIMESTAMP
GQL
RETURN zoned_datetime("2025-01-01T12:20:02+08:00"),
       zoned_datetime("2025-01-01T12:20:02Z"),
       zoned_datetime({year: 2025, month: 1, day: 1, hour: 12, minute: 20, second: 2, timezone: "+08:00"}),
       zoned_datetime({year: 2025, month: 1, day: 1, hour: 12, minute: 20, second: 2, timezone: "+08:00", millisecond: 500}),
       zoned_datetime({year: 2025, month: 1, day: 1, hour: 12, minute: 20, second: 2, timezone: "-06:00", microsecond: 700}),
       zoned_datetime({year: 2025, month: 1, day: 1, hour: 12, minute: 20, second: 2, timezone: "Z", nanosecond: 700})

Convert an existing datetime to a different timezone:

GQL
RETURN zoned_datetime("2025-01-01T12:20:02+08:00", "+05:30")

now()

Returns the current zoned datetime in the server's local timezone. It is equivalent to CURRENT_TIMESTAMP.

Syntaxnow()
Return TypeZONED DATETIME
GQL
RETURN now(), CURRENT_TIMESTAMP

duration()

Creates a value of type DURATION.

Syntaxduration(<durationStr>)
ArgumentsNameTypeDescription
<durationStr>STRINGAn ISO 8601 duration string (e.g., "P2Y5M", "P3DT4H")
Return TypeDURATION
GQL
RETURN duration("P2Y5M"), duration("P3DT4H30M")

Other Datetime Functions

date_add()

Adds a specified time interval to a given date.

Syntaxdate_add(<time>, <interval>, <unit>)
ArgumentsNameTypeDescription
<time>TemporalThe initial time
<interval>INTThe number of units to add (positive value to add, negative to subtract)
<unit>STRINGThe unit of time to add, which can be year, month, day, hour, minute, or second
Return TypeDATETIME
GQL
RETURN date_add("1970-1-1", -1, "hour")

Result:

JSON
{
  "_type": "localDatetime",
  "year": 1969,
  "month": 12,
  "day": 31,
  "hour": 23,
  "minute": 0,
  "second": 0,
  "nanosecond": 0
}
GQL
RETURN date_add("1970-1-1", 10, "year")

Result:

JSON
{
  "_type": "localDatetime",
  "year": 1980,
  "month": 1,
  "day": 1,
  "hour": 0,
  "minute": 0,
  "second": 0,
  "nanosecond": 0
}

date_diff()

Computes the difference between two dates (time1 - time2) and returns the result as a specified unit of time.

Syntaxdate_diff(<time1>, <time2>, <unit>)
ArgumentsNameTypeDescription
<endTime>TemporalThe first time
<time2>TemporalThe second time
<unit>STRINGThe unit of difference, which can be day, hour, minute, or second
Return TypeDATETIME
GQL
RETURN date_diff("1970-01-01 10:00:00", "1970-01-01 12:00:20", "minute")

Result: -120

day_of_week()

Returns a number (from 0 to 6, where 0 = Sunday and 6 = Saturday) representing the day of the week for a given date.

Syntaxday_of_week(<time>)
ArgumentsNameTypeDescription
<time>STRING or TemporalA date/time string or a temporal value (DATE, LOCAL DATETIME, ZONED DATETIME, LOCAL TIME, TIMESTAMP)
Return TypeINT
GQL
RETURN day_of_week("2024-12-5")

Result: 4

year()

Extracts the year from a date or datetime value.

Syntaxyear(<temporal>)
ArgumentsNameTypeDescription
<temporal>STRING or TemporalA date/time string or a temporal value (DATE, LOCAL DATETIME, ZONED DATETIME, LOCAL TIME, TIMESTAMP)
Return TypeINT
GQL
RETURN year("2025-03-15"), year(date("2025-03-15"))

month()

Extracts the month from a date or datetime value.

Syntaxmonth(<temporal>)
ArgumentsNameTypeDescription
<temporal>STRING or TemporalA date/time string or a temporal value (DATE, LOCAL DATETIME, ZONED DATETIME, LOCAL TIME, TIMESTAMP)
Return TypeINT
GQL
RETURN month("2025-03-15"), month(date("2025-03-15"))

day()

Extracts the day from a date or datetime value.

Syntaxday(<temporal>)
ArgumentsNameTypeDescription
<temporal>STRING or TemporalA date/time string or a temporal value (DATE, LOCAL DATETIME, ZONED DATETIME, LOCAL TIME, TIMESTAMP)
Return TypeINT
GQL
RETURN day("2025-03-15"), day(date("2025-03-15"))

hour()

Extracts the hour from a time or datetime value.

Syntaxhour(<temporal>)
ArgumentsNameTypeDescription
<temporal>STRING or TemporalA date/time string or a temporal value (DATE, LOCAL DATETIME, ZONED DATETIME, LOCAL TIME, TIMESTAMP)
Return TypeINT
GQL
RETURN hour("2025-03-15 14:30:45"), hour(local_datetime("2025-03-15 14:30:45"))

minute()

Extracts the minute from a time or datetime value.

Syntaxminute(<temporal>)
ArgumentsNameTypeDescription
<temporal>STRING or TemporalA date/time string or a temporal value (DATE, LOCAL DATETIME, ZONED DATETIME, LOCAL TIME, TIMESTAMP)
Return TypeINT
GQL
RETURN minute("2025-03-15 14:30:45"), minute(local_datetime("2025-03-15 14:30:45"))

second()

Extracts the second from a time or datetime value.

Syntaxsecond(<temporal>)
ArgumentsNameTypeDescription
<temporal>STRING or TemporalA date/time string or a temporal value (DATE, LOCAL DATETIME, ZONED DATETIME, LOCAL TIME, TIMESTAMP)
Return TypeINT
GQL
RETURN second("2025-03-15 14:30:45"), second(local_datetime("2025-03-15 14:30:45"))

duration_between()

Computes the duration between two temporal values.

Syntaxduration_between(<temporal1>, <temporal2>)
ArgumentsNameTypeDescription
<temporal1>DATE, DATETIME, TIMESTAMPStart temporal value
<temporal2>DATE, DATETIME, TIMESTAMPEnd temporal value
Return TypeDURATION
GQL
RETURN duration_between(date("2025-01-01"), date("2025-03-15"))

Result:

JSON
{
  "seconds": 6307200, "nanoseconds": 0
}

dateformat()

Formats a temporal value as a string using a Java SimpleDateFormat-style pattern.

Syntaxdateformat(<temporal>, <format>)
ArgumentsNameTypeDescription
<temporal>TemporalA datetime value or a parsable string
<format>STRINGA Java SimpleDateFormat-style pattern (e.g., "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss")
Return TypeSTRING

Supported pattern tokens (case-sensitive; the longest match wins):

TokenMeaningExample
yyyy / yy4- or 2-digit year2024 / 24
MMMMM / MMMM / MMM / MM / MMonth: one-letter abbreviation / full name / short name / 2-digit / 1-digitJ / January / Jan / 01 / 1
dd / dDay of month: padded / unpadded02 / 2
EEEE / EEE / EE / EDay name: full / 3-letter abbreviationMonday / Mon
HH / HHour 0-23, always 2-digit padded15
hh / hHour 1-12: padded / unpadded03 / 3
mm / mMinute: padded / unpadded04 / 4
ss / sSecond: padded / unpadded05 / 5
SSSSSSSSS / SSSSSS / SSS / SS / SFractional second: 9 / 6 / 3 / 2 / 1 digits (use after . or ,)123456789 / 123456 / 123 / 12 / 1
aAM/PM markerPM
XXX / XX / XISO 8601 zone offset-07:00 / -0700 / -07
ZRFC 822 zone offset-0700
zTime zone abbreviationMST
GQL
RETURN dateformat(date("2025-03-15"), "yyyy-M-d") AS value1,
       dateformat(local_datetime("2025-03-15T14:30:45"), "yyyy-MM-dd HH:mm:ss") AS value2
       dateformat(CURRENT_DATE, "'today is' yyyy-MM-dd") AS value3  // single-quote escape

Result:

value1value2value3
"2025-3-15""2025-03-15 14:30:45""today is 2026-05-18"