HarperDB utilizes Coordinated Universal Time (UTC) in all internal SQL operations. This means that date values passed into any of the functions below will be assumed to be in UTC or in a format that can be translated to UTC.
When parsing date values passed to SQL date functions in HDB, we first check for ISO 8601 formats, then for RFC 2822 date-time format and then fall back to new Date(date_string)if a known format is not found.
Returns the current date in UTC in YYYY-MM-DD
String format.
Returns the current time in UTC in HH:mm:ss.SSS
String format.
Referencing this variable will evaluate as the current Unix Timestamp in milliseconds.
Formats and returns the date_string argument in UTC in YYYY-MM-DDTHH:mm:ss.SSSZZ
String format.
If a date_string is not provided, the function will return the current UTC date/time value in the return format defined above.
Adds the defined amount of time to the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted interval values: Either string value (key or shorthand) can be passed as the interval argument.
Returns the difference between the two date values passed based on the interval as a Number. If an interval is not provided, the function will return the difference value in milliseconds.
Accepted interval values:
years
months
weeks
days
hours
minutes
seconds
Formats and returns a date value in the String format provided. Find more details on accepted format values in the moment.js docs.
Subtracts the defined amount of time from the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted date_sub interval values- Either string value (key or shorthand) can be passed as the interval argument.
Extracts and returns the date_part requested as a String value. Accepted date_part values below show value returned for date = “2020-03-26T15:13:02.041+000”
Returns the current Unix Timestamp in milliseconds.
Returns the current date/time value based on the server’s timezone in YYYY-MM-DDTHH:mm:ss.SSSZZ
String format.
Returns the UTC date time value with the offset provided included in the return String value formatted as YYYY-MM-DDTHH:mm:ss.SSSZZ
. The offset argument will be added as minutes unless the value is less than 16 and greater than -16, in which case it will be treated as hours.
Returns the current Unix Timestamp in milliseconds.
Key | Shorthand |
---|---|
Key | Shorthand |
---|---|
date_part | Example return value* |
---|---|
years
y
quarters
Q
months
M
weeks
w
days
d
hours
h
minutes
m
seconds
s
milliseconds
ms
years
y
quarters
Q
months
M
weeks
w
days
d
hours
h
minutes
m
seconds
s
milliseconds
ms
year
“2020”
month
“3”
day
“26”
hour
“15”
minute
“13”
second
“2”
millisecond
“41”