Click to See Complete Forum and Search --> : Last_Day in PostgreSql


Sanjeev131
July 15th, 2003, 03:50 AM
Hi All,
As there is a function in Oracle that supports Last_day() , do we have a similar function in Postgresql . I need to find out the last day of the given date.
Its an urgent requirement. Any help would be highly appreciated . Thanks in advance.
bye
Sanjeev

Thread1
July 17th, 2003, 04:27 AM
Hi,

Well, it seems that there's no such function in PostgreSQL. The following SQL statement does the same thing, if you want you can convert it into a function so that you can save the current_date into a variable..


select case when date_part('month', current_date) in (1,3,5,7,8,10,12) then 31
when date_part('month', current_date) = 2 and date_part('year', current_date)::int4 % 4 = 0 then 29
when date_part('month', current_date) = 2 then 28
else 30
end;


I hope that helps:cool:

Sanjeev131
July 17th, 2003, 04:46 AM
Thanks a lot for the logic i will try out this .