Datetime Functions
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()
Syntax
datetime_add( date, INTERVAL int_value time_unit )
Description
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
.
Return type
DATETIME
Parameters
Parameter | Description | Data type |
| The |
|
| An integer value |
|
Example
datetime_diff()
datetime_diff()
Syntax
datetime_diff( date1, date2 )
Description
Calculates the difference in seconds between two DATETIME
values
Return type
INT
Parameters
Parameter | Description | Data type |
| A |
|
| A |
|
Example
datetime_format()
datetime_format()
Syntax
datetime_format(date[, str])
Description
Print a DATETIME
value in a specific format indicated by a string.
Return type
STRING
Parameters
Parameter | Description | Data type |
| A |
|
| A string pattern expressing the format to print
The default value for this parameter is |
|
Example
datetime_sub( )
datetime_sub( )
Syntax
datetime_sub(date, INTERVAL int_value time_unit)
Description
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
.
Return type
DATETIME
Parameters
Parameter | Description | Data type |
| The |
|
| An integer value |
|
Example
datetime_to_epoch()
datetime_to_epoch()
Syntax
datetime_to_epoch( date )
Description
Converts a DATETIME
value to epoch time.
Return type
INT
Parameters
Parameter | Description | Data type |
| A |
|
Example
day()
day()
Syntax
day( date )
Description
Returns the day of the month of a DATETIME
value.
Return type
INT
Parameters
Parameter | Description | Data type |
| A |
|
Example
epoch_to_datetime()
epoch_to_datetime()
Syntax
epoch_to_datetime(int_value)
Description
Converts an epoch time value to a DATETIME
value.
Return type
DATETIME
Parameters
Parameter | Description | Data type |
| An epoch time value |
|
Example
hour()
hour()
Syntax
hour(date)
Description
Extracts the hour of the day from a DATETIME
value.
Return type
INT
Parameters
Parameter | Description | Data type |
| A |
|
Example
minute()
minute()
Syntax
minute(date)
Description
Extracts the minute of the hour from a DATETIME
value.
Return type
INT
Parameters
Parameter | Description | Data type |
| A |
|
Example
month()
month()
Syntax
month(date)
Description
Extracts the month of the year from a DATETIME
value.
Return type
Parameters
Parameter | Description | Data type |
| A |
|
Example
now()
now()
Syntax
now()
Description
Returns the current time in DATETIME
Return type
DATETIME
Parameters
None.
second()
second()
Syntax
second(date)
Description
Extracts the second from a DATETIME
value.
Return type
INT
Parameters
Parameter | Description | Data type |
| A |
|
Example
year()
year()
Syntax
year(date)
Description
Extracts the year from a DATETIME
value.
Return type
Parameters
Parameter | Description | Data type |
| A |
|
Example
Last updated