pg.ddx.io pgsql-docs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
the date() function is undocumented while quite necessary 2+ messages / 2 participants [nested] [flat]
* the date() function is undocumented while quite necessary @ 2020-02-15 15:06 PG Doc comments form <noreply@postgresql.org> 2020-02-15 16:36 ` Re: the date() function is undocumented while quite necessary Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 2+ messages in thread From: PG Doc comments form @ 2020-02-15 15:06 UTC (permalink / raw) To: pgsql-docs@lists.postgresql.org; +Cc: sgarden@club.fr The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/12/functions-datetime.html Description: I can't find anywhere the documentation of the SQL DATE() function which extracts the date part out of a timestamp. Please note that according to my tests, one can't use the cast operator when defining expression-based indexes, while the date(column) expression is accepted. It makes the DATE() function way more useful than one may think. ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: the date() function is undocumented while quite necessary 2020-02-15 15:06 the date() function is undocumented while quite necessary PG Doc comments form <noreply@postgresql.org> @ 2020-02-15 16:36 ` Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2020-02-15 16:36 UTC (permalink / raw) To: sgarden@club.fr; +Cc: pgsql-docs@lists.postgresql.org PG Doc comments form <noreply@postgresql.org> writes: > I can't find anywhere the documentation of the SQL DATE() function which > extracts the date part out of a timestamp. It's a type cast written in function-like syntax, as documented in https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS We don't really encourage that notation, because it's confusing and it doesn't work for every possible type name, which is why you won't find it mentioned very many places. > Please note that according to my tests, one can't use the cast operator when > defining expression-based indexes, while the date(column) expression is > accepted. You can if you put parentheses around it: regression=# create table t1 (f1 timestamp); CREATE TABLE regression=# create index on t1 (f1::date); ERROR: syntax error at or near "::" LINE 1: create index on t1 (f1::date); ^ regression=# create index on t1 ((f1::date)); CREATE INDEX This is per the restriction explained in the CREATE INDEX docs, that any expression-to-be-indexed that doesn't look like a function call requires parentheses. https://www.postgresql.org/docs/current/indexes-expressional.html https://www.postgresql.org/docs/current/sql-createindex.html regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-02-15 16:36 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-02-15 15:06 the date() function is undocumented while quite necessary PG Doc comments form <noreply@postgresql.org> 2020-02-15 16:36 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox