public inbox for [email protected]
help / color / mirror / Atom feedArgument 'week' not supported in date_trunc function with intervals
2+ messages / 2 participants
[nested] [flat]
* Argument 'week' not supported in date_trunc function with intervals
@ 2020-01-03 12:31 PG Doc comments form <[email protected]>
2020-01-18 02:20 ` Re: Argument 'week' not supported in date_trunc function with intervals Bruce Momjian <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: PG Doc comments form @ 2020-01-03 12:31 UTC (permalink / raw)
To: [email protected]; +Cc: [email protected]
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/12/functions-datetime.html
Description:
In the documentation of the date_trunc function (9.9.2), the first argument
(field) cannot be 'week' if the second argument (source) is an interval:
csauer=# SELECT DATE_TRUNC('week', INTERVAL '7 days');
ERROR: interval units "week" not supported because months usually have
fractional weeks
csauer=# SELECT DATE_TRUNC('week', INTERVAL '1 week');
ERROR: interval units "week" not supported because months usually have
fractional weeks
The documentation should state that explicitly.
I also think the error message could be improved, because in the cases above
there are no months involved and the result should be 1.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Argument 'week' not supported in date_trunc function with intervals
2020-01-03 12:31 Argument 'week' not supported in date_trunc function with intervals PG Doc comments form <[email protected]>
@ 2020-01-18 02:20 ` Bruce Momjian <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Momjian @ 2020-01-18 02:20 UTC (permalink / raw)
To: [email protected]; [email protected]
On Fri, Jan 3, 2020 at 12:31:27PM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/12/functions-datetime.html
> Description:
>
> In the documentation of the date_trunc function (9.9.2), the first argument
> (field) cannot be 'week' if the second argument (source) is an interval:
>
> csauer=# SELECT DATE_TRUNC('week', INTERVAL '7 days');
>
>
>
> ERROR: interval units "week" not supported because months usually have
> fractional weeks
> csauer=# SELECT DATE_TRUNC('week', INTERVAL '1 week');
>
>
>
> ERROR: interval units "week" not supported because months usually have
> fractional weeks
>
> The documentation should state that explicitly.
>
> I also think the error message could be improved, because in the cases above
> there are no months involved and the result should be 1.
Uh, we could modify the code so that we allow SELECT DATE_TRUNC('week',
INTERVAL '') to work if there is no month component, since interval is
made up of months, days, and time. However, this would mean the
function would work with some interval values, and not others. Is that
an improvement?
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-01-18 02:20 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-01-03 12:31 Argument 'week' not supported in date_trunc function with intervals PG Doc comments form <[email protected]>
2020-01-18 02:20 ` Bruce Momjian <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox