This page lists DATETIME
functions that are available in the GSQL query language. Every function in this page either takes a DATETIME
object as its argument or return a DATETIME
object.
datetime_add()
datetime_add( date, INTERVAL int_value time_unit )
Calculates a new DATETIME
from a specified datepart multiplied by a specified amount, added to a specified DATETIME
.INTERVAL
is a keyword that must be exactly entered. time_unit
is one of the keywords YEAR
, MONTH
, DAY
, HOUR
, MINUTE
, or SECOND
.
DATETIME
datetime_diff()
datetime_diff( date1, date2 )
Calculates the difference in seconds between two DATETIME
values
INT
datetime_format()
datetime_format(date[, str])
Print a DATETIME
value in a specific format indicated by a string.
STRING
datetime_sub( )
datetime_sub(date, INTERVAL int_value time_unit)
Calculates a new DATETIME
from a specified datepart multiplied by a specified amount, subtracted from a specified DATETIME
.INTERVAL
is a keyword that must be exactly entered. time_unit
is one of the keywords YEAR
, MONTH
, DAY
, HOUR
, MINUTE
, or SECOND
.
DATETIME
datetime_to_epoch()
datetime_to_epoch( date )
Converts a DATETIME
value to epoch time.
INT
day()
day( date )
Returns the day of the month of a DATETIME
value.
INT
epoch_to_datetime()
epoch_to_datetime(int_value)
Converts an epoch time value to a DATETIME
value.
DATETIME
hour()
hour(date)
Extracts the hour of the day from a DATETIME
value.
INT
minute()
minute(date)
Extracts the minute of the hour from a DATETIME
value.
INT
month()
month(date)
Extracts the month of the year from a DATETIME
value.
now()
now()
Returns the current time in DATETIME
DATETIME
None.
second()
second(date)
Extracts the second from a DATETIME
value.
INT
year()
year(date)
Extracts the year from a DATETIME
value.
Parameter
Description
Data type
date
The DATETIME
to add to.
DATETIME
int_value
An integer value
INT
Parameter
Description
Data type
date1
A DATETIME
value
DATETIME
date2
A DATETIME
value
DATETIME
Parameter
Description
Data type
date
A DATETIME
value
DATETIME
str
A string pattern expressing the format to print date
in. Use the following specifiers in your string to insert the corresponding value in the output.
%Y
- year
%m
- month
%d
- day of month
%H
- hour
%M
- minute
%S
- second
The default value for this parameter is "%Y-%m-%d %H:%M:%S"
DATETIME
Parameter
Description
Data type
date
The DATETIME
to subtract from
DATETIME
int_value
An integer value
INT
Parameter
Description
Data type
date
A DATETIME
value
DATETIME
Parameter
Description
Data type
date
A DATETIME
value
DATETIME
Parameter
Description
Data type
int_value
An epoch time value
INT
Parameter
Description
Data type
date
A DATETIME
value
DATETIME
Parameter
Description
Data type
date
A DATETIME
value
DATETIME
Parameter
Description
Data type
date
A DATETIME
value
DATETIME
Parameter
Description
Data type
date
A DATETIME
value
DATETIME
Parameter
Description
Data type
date
A DATETIME
value
DATETIME