Skip to main content

DATE

Returns a date string in the format YYYY-MM-DD.

See also:
[SELECT] [ Date Modifiers ]


Syntax

SELECT DATE(datetime_expression [, modifier, ...]) FROM <multipartIdentifier>;

Arguments

datetime_expression
The datetime value.

modifier
Zero or more modifiers to be applied to the datetime_expression. For more information about modifiers, see Date Modifiers

Return Value(s)

Returns a string representing the date component of the input datetime_expression with the modifier applied.


Examples

Return the date component of a datetime value

SELECT name, timeCreated,
date(timeCreated) as date_only
FROM google.storage.buckets WHERE project = 'stackql';

Return the local date component of a datetime value

SELECT name, timeCreated,
date(timeCreated, 'localtime') as local_date
FROM google.storage.buckets WHERE project = 'stackql';

For more information, see https://www.sqlite.org/lang_datefunc.html