Date and Time Functions
Reference of the SQL date and time functions supported by GridGain — current date/time, DATEADD, DATEDIFF, EXTRACT, formatting, and component extraction.
CURRENT_DATE
Description
Returns the current date. When called multiple times within a transaction, returns the same value.
{CURRENT_DATE [()] | CURDATE() | SYSDATE | TODAY}Example
Return the current date:
CURRENT_DATE()CURRENT_TIME
Description
Returns the current time.
{CURRENT_TIME [ () ] | CURTIME()}Example
Return the current time:
CURRENT_TIMESTAMP
Description
Returns the current timestamp. When called multiple times within a transaction, returns the same value.
Parameters
int - (optional) the precision parameter for nanoseconds - the number of digits after the decimal point (for example, 9 is nanoseconds)
Example
Return the current timestamp:
DATEADD | TIMESTAMPADD
Description
Adds units to the timestamp or date (if the value is positive). Subtracts units from the timestamp or date (if the value is negative). The DATEADD function returns a timestamp. The TIMESTAMPADD function returns a long.
Parameters
unitString- the unit to add or subtract (see the EXTRACT function for supported units)addIntLong- the number of units to add or subtract; may belongwhen manipulating milliseconds,intotherwisetimestamp- the timestamp to add units to
Example
Add 1 month to Jan 31 2021:
DATEDIFF
Description
Returns the number of specified units that differentiate between two timestamps as a long.
Parameters
unitString- the unit to consider (see the EXTRACT function for supported units)aTimestamp- the first timestamp to comparebTimestamp- the second timestamp to compare
Example
Return the number of years that differentiate T1.CREATED from T2.CREATED:
DAYNAME
Description
Returns the name of the day of the week (in English).
Parameters
date - the date to process
Example
Return the day of the week for CREATED:
DAY_OF_MONTH
Description
Returns the day of the month (1-31).
Parameters
date - the date to process
Example
Return the day of the month for CREATED:
DAY_OF_WEEK
Description
Returns the day of the week (1-7, 1=Sunday).
Parameters
date - the date to process
Example
Return the number of the day of the week for CREATED:
DAY_OF_YEAR
Description
Returns the day of the year (1-366).
Parameters
date - the date to process
Example
Return the number of the day of the year for CREATED:
EXTRACT
Description
Returns a specific value from a timestamp as an int.
Parameters
timestamp - the timestamp to process
Example
Extract the value of the 'seconds' part from CURRENT_TIMESTAMP:
FORMATDATETIME
Description
Formats a date, time, or timestamp as a string. The main format characters are: y year, M month, d day, H hour, m minute, and s second. For more details, see the java.text.SimpleDateFormat method.
Parameters
timestamp- the timestamp to processformatString- the format to applylocaleString- the name of the localetimeZoneString- the time zone
Example
Format 2001-02-03 04:05:06 in English for GMT using the 'EEE, d MMM yyyy HH:mm:ss z' format:
HOUR
Description
Returns the hour (0-23) from a timestamp.
Parameters
timestamp - the timestamp to process
Example
Return the number of hours for CREATED:
MINUTE
Description
Returns the minutes (0-59) from a timestamp.
Parameters
timestamp - the timestamp to process
Example
Return the number of minutes from CREATED:
MONTH
Description
Returns the month (1-12) from a timestamp.
Parameters
timestamp - the timestamp to process
Example
Return the months from CREATED:
MONTHNAME
Description
Returns the name of the month (in English).
Parameters
date - the date to process
Example
Return the name of the month from CREATED:
PARSEDATETIME
Description
Parses a string and converts it to timestamp. The main characters in the string format are: y year, M month, d day, H hour, m minute, and s second. For more details, see the java.text.SimpleDateFormat method.
Parameters
string- the string top parseformatString- the string formatlocaleString- the name of the localetimeZoneString- the time zone
Example
Convert to timestamp the 'Sat, 3 Feb 2001 03:05:06 GMT':
QUARTER
Description
Returns the quarter (1-4) from a timestamp.
Parameters
timestamp - the timestamp to process
Example
Return the quarter for CREATED:
SECOND
Description
Returns the second (0-59) from a timestamp.
Parameters
timestamp - the timestamp to process
Example
Return the number of seconds for CREATED:
WEEK
Description
Returns the week (1-53) from a timestamp using the current system locale.
Parameters
timestamp - the timestamp to process
Example
Return the number of the week from CREATED:
YEAR
Description
Returns the year from a timestamp.
Parameters
timestamp - the timestamp to process
Example
Return the year from CREATED:
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

