Skip site navigation (1) Skip section navigation (2)

date_part patch

From: Marc Balmer <marc(at)msys(dot)ch>
To: pgsql-patches(at)postgresql(dot)org
Subject: date_part patch
Date: 2001-09-09 08:53:15
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
Attached is small patch that extends the date_part function to return the
day of week and day of year respectively.

Two new tokens are introduced, weekday and yearday to allow
for the retrieval of the day number since sunday (0-6) or the day
number since january, 1 from a date value.

I use it to retrieve events on specific weekdays, e.g. all events
that occur on mondays:

SELECT * FROM events WHERE date_part('weekday', eventdate) = 1;

The following files are patched:

Extends "units" table to recognize the new tokens

Extends timestamp2tm() function to return the fields tm_mday and tm_yday
Extends timestamp_part() function to return the day of week or day of year

Defines new tokens DTK_WEEKDAY, DTK_YEARDAY

<Der Anhang fehlt>
Marc Balmer, Micro Systems, Kannenfeldstrasse 32, CH-4056 Basel
Tel +41 61 383 05 10, Fax +41 61 383 05 12,


pgsql-patches by date

Next:From: Jeroen van VianenDate: 2001-09-09 12:48:41
Subject: Re: [HACKERS] JDBC pg_description update needed for CVS
Previous:From: Michael MeskesDate: 2001-09-09 08:10:12
Subject: Re: ECPG enhancements / fixes

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group