Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a8aa2f9

Browse files
author
Thomas G. Lockhart
committed
Repair always-broken date_part('quarter',timestamp).
Previous result did not have correct month boundaries so anything near edge cases was suspect (e.g. April was in Q1 and July, August were lumped into Q2). Thanks to Denis Osadchy <osadchy@turbo.nsk.su> for the report.
1 parent 39f987c commit a8aa2f9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.40 2000/12/07 18:38:59 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.41 2001/01/03 16:48:02 thomas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1887,9 +1887,9 @@ interval_trunc(PG_FUNCTION_ARGS)
18871887
}
18881888

18891889
/* isoweek2date()
1890-
*
1891-
* Convert ISO week of year number to date. An year must be already set.
1892-
* karel 2000/08/07
1890+
* Convert ISO week of year number to date.
1891+
* The year field must be specified!
1892+
* karel 2000/08/07
18931893
*/
18941894
void
18951895
isoweek2date( int woy, int *year, int *mon, int *mday)
@@ -2053,7 +2053,7 @@ timestamp_part(PG_FUNCTION_ARGS)
20532053
break;
20542054

20552055
case DTK_QUARTER:
2056-
result = (tm->tm_mon / 4) + 1;
2056+
result = ((tm->tm_mon - 1) / 3) + 1;
20572057
break;
20582058

20592059
case DTK_WEEK:

0 commit comments

Comments
 (0)