s3-glacier-select-sql-reference-date
Date Functions
Amazon S3 Select and S3 Glacier Select support the following date functions.
Topics
DATE_ADD
Given a date part, a quantity, and a time stamp, returns an updated time stamp by altering the date part by the quantity.
Syntax
Parameters
date_part
Specifies which part of the date to modify. This can be one of the following:
year
month
day
hour
minute
second
quantity
The value to apply to the updated time stamp. Positive values for quantity add to the time stamp's date_part, and negative values subtract.timestamp
The target time stamp that the function operates on.
Examples
DATE_DIFF
Given a date part and two valid time stamps, returns the difference in date parts. The return value is a negative integer when the date_part
value of timestamp1
is greater than the date_part
value of timestamp2
. The return value is a positive integer when the date_part
value of timestamp1
is less than the date_part
value of timestamp2
.
Syntax
Parameters
date_part
Specifies which part of the time stamps to compare. For the definition of date_part
, see DATE_ADD.
timestamp1
The first time stamp to compare.
timestamp2
The second time stamp to compare.
Examples
EXTRACT
Given a date part and a time stamp, returns the time stamp's date part value.
Syntax
Parameters
date_part
Specifies which part of the time stamps to extract. This can be one of the following:
year
month
day
hour
minute
second
timezone_hour
timezone_minute
timestamp
The target time stamp that the function operates on.
Examples
TO_STRING
Given a time stamp and a format pattern, returns a string representation of the time stamp in the given format.
Syntax
Parameters
timestamp
The target time stamp that the function operates on.
time_format_pattern
A string that has the following special character interpretations.
[See the AWS documentation website for more details]
Examples
TO_TIMESTAMP
Given a string, converts it to a time stamp. This is the inverse operation of TO_STRING.
Syntax
Parameters
string
The target string that the function operates on.
Examples
UTCNOW
Returns the current time in UTC as a time stamp.
Syntax
Parameters
none