Обсуждение: LAST_DAY Function in Postgres

Поиск
Список
Период
Сортировка

LAST_DAY Function in Postgres

От
"Amin Schoeib"
Дата:

Hi,
I would like to know if there is a Function in Postgres
Like the LAST_DAY Function in Oracle??
In Oracle you can use the function the get the last day of a month.

Thanxx

Schoeib

4Tek Gesellschaft für angewandte Informationstechnologien mbH
Schoeib Amin
Tel.  +49 (0) 69 697688-132
Fax. +49 (0) 69 697688-111
http://www.4tek.de

CPAN, P for postgresql [Re: LAST_DAY Function in Postgres]

От
"Shridhar Daithankar"
Дата:
On 2 Sep 2003 at 15:08, Amin Schoeib wrote:
> I would like to know if there is a Function in Postgres
> Like the LAST_DAY Function in Oracle??
> In Oracle you can use the function the get the last day of a month.

While this is not a direct answer to question..

It made me think. I am sure lot of people have lot of functions written in
order to get job done. Can we have an archive of such functions, if authors are
willing to make it open.

Something like CPAN? Yeah we don't need to change that name..:-)

Bye
 Shridhar

--
"...very few phenomena can pull someone out of Deep Hack Mode, with twonoted
exceptions: being struck by lightning, or worse, your *computer*being struck by
lightning."(By Matt Welsh)


Re: LAST_DAY Function in Postgres

От
Pavel Stehule
Дата:
Hi,

if didn't find this function on
http://www.postgresql.org/docs/7.3/interactive/functions-datetime.html,
You have to write own function

testdb=> create or replace function last_day(date) returns date as 'select
cast(date_trunc(''month'', $1) + ''1 month''::interval as date) - 1'
language sql;
CREATE FUNCTION
testdb=> select last_day(current_date);
  last_day
------------
 2003-09-30
(1 řádka)

Bye
Pavel


On Tue, 2 Sep 2003, Amin Schoeib wrote:

> Hi,
> I would like to know if there is a Function in Postgres
> Like the LAST_DAY Function in Oracle??
> In Oracle you can use the function the get the last day of a month.
>
> Thanxx
>
> Schoeib
>
>
> 4Tek Gesellschaft für angewandte Informationstechnologien mbH
> Schoeib Amin
> Tel.  +49 (0) 69 697688-132
> Fax. +49 (0) 69 697688-111
> http://www.4tek.de
>
>


Re: CPAN, P for postgresql [Re: LAST_DAY Function in

От
Pavel Stehule
Дата:
On Tue, 2 Sep 2003, Shridhar Daithankar wrote:

> On 2 Sep 2003 at 15:08, Amin Schoeib wrote:
> > I would like to know if there is a Function in Postgres
> > Like the LAST_DAY Function in Oracle??
> > In Oracle you can use the function the get the last day of a month.
>
> While this is not a direct answer to question..
>
> It made me think. I am sure lot of people have lot of functions written in
> order to get job done. Can we have an archive of such functions, if authors are
> willing to make it open.
>
> Something like CPAN? Yeah we don't need to change that name..:-)
>

Cookbook pages?

http://www.brasileiro.net/postgres/cookbook/

Pavel

> Bye
>  Shridhar
>
> --
> "...very few phenomena can pull someone out of Deep Hack Mode, with twonoted
> exceptions: being struck by lightning, or worse, your *computer*being struck by
> lightning."(By Matt Welsh)
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


Re: CPAN, P for postgresql [Re: LAST_DAY Function in Postgres]

От
Bruce Momjian
Дата:
Shridhar Daithankar wrote:
> On 2 Sep 2003 at 15:08, Amin Schoeib wrote:
> > I would like to know if there is a Function in Postgres
> > Like the LAST_DAY Function in Oracle??
> > In Oracle you can use the function the get the last day of a month.
>
> While this is not a direct answer to question..
>
> It made me think. I am sure lot of people have lot of functions written in
> order to get job done. Can we have an archive of such functions, if authors are
> willing to make it open.
>
> Something like CPAN? Yeah we don't need to change that name..:-)

There is the PostgreSQL Cookbook on the techdocs web site.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: CPAN, P for postgresql [Re: LAST_DAY Function in Postgres]

От
elein
Дата:
I also have a small, but growing collection of *stuff*
off of the General Bits site as well as a number of
useful functions with explanations in lots of articles.

 From http://www.varlena.com/GeneralBits/

Search with local google or look through tidbits
and the Archives.

--elein

On Wed, Sep 03, 2003 at 04:43:28PM -0400, Bruce Momjian wrote:
> Shridhar Daithankar wrote:
> > On 2 Sep 2003 at 15:08, Amin Schoeib wrote:
> > > I would like to know if there is a Function in Postgres
> > > Like the LAST_DAY Function in Oracle??
> > > In Oracle you can use the function the get the last day of a month.
> >
> > While this is not a direct answer to question..
> >
> > It made me think. I am sure lot of people have lot of functions written in
> > order to get job done. Can we have an archive of such functions, if authors are
> > willing to make it open.
> >
> > Something like CPAN? Yeah we don't need to change that name..:-)
>
> There is the PostgreSQL Cookbook on the techdocs web site.
>
> --
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 359-1001
>   +  If your life is a hard drive,     |  13 Roberts Road
>   +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)