By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

LAST_DAY Function in Postgres

P: n/a
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 fr angewandte Informationstechnologien mbH
Schoeib Amin
Tel. +49 (0) 69 697688-132
Fax. +49 (0) 69 697688-111
http://www.4tek.de
Nov 11 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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)
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 11 '05 #2

P: n/a
Hi,

if didn't find this function on
http://www.postgresql.org/docs/7.3/i...-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 fr angewandte Informationstechnologien mbH
Schoeib Amin
Tel. +49 (0) 69 697688-132
Fax. +49 (0) 69 697688-111
http://www.4tek.de

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 11 '05 #3

P: n/a
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 ma*******@postgresql.org)

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #4

P: n/a
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
pg***@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 ma*******@postgresql.org)

Nov 11 '05 #5

P: n/a
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
pg***@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 ma*******@postgresql.org)


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.