Skip to content

Commit 083b913

Browse files
committed
On second thought, explain why date_trunc("week") on interval values is
not supported in the error message, rather than the docs.
1 parent 74f4881 commit 083b913

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

doc/src/sgml/func.sgml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7050,11 +7050,6 @@ date_trunc('<replaceable>field</replaceable>', <replaceable>source</replaceable>
70507050
</simplelist>
70517051
</para>
70527052

7053-
<para>
7054-
<literal>week</literal> is not supported for <type>interval</>
7055-
values because months usually have fractional weeks.
7056-
</para>
7057-
70587053
<para>
70597054
Examples:
70607055
<screen>

src/backend/utils/adt/timestamp.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,10 +3710,17 @@ interval_trunc(PG_FUNCTION_ARGS)
37103710
break;
37113711

37123712
default:
3713-
ereport(ERROR,
3714-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3715-
errmsg("interval units \"%s\" not supported",
3716-
lowunits)));
3713+
if (val == DTK_WEEK)
3714+
ereport(ERROR,
3715+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3716+
errmsg("interval units \"%s\" not supported "
3717+
"because months usually have fractional weeks",
3718+
lowunits)));
3719+
else
3720+
ereport(ERROR,
3721+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3722+
errmsg("interval units \"%s\" not supported",
3723+
lowunits)));
37173724
}
37183725

37193726
if (tm2interval(tm, fsec, result) != 0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy