R: find last day of month - Mailing list pgsql-general

From Luciano Bastianello
Subject R: find last day of month
Date
Msg-id 001d01c5fd0d$bb786940$220ba8c0@SFERA
Whole thread Raw
List pgsql-general
>> "Andrus Moor" <eetasoft@online.ee> writes:
>>
>>> I have a table containing month column in format mm.yyyy
>>>
>>> create table months ( tmkuu c(7));
>>> insert into months values ('01.2005');
>>> insert into months values ('02.2005');
>>>
>>> How to create select statement which converts this column to date
>>> type containing last day of month like
>>>
>>> '2005-01-31'
>>> '2005-02-28'
>>
>> The usual trick is to split it into year and month, add 1 to the
>> month, if that's > 12, jump to 1, and add a year.
>>
>> Based on those...  Construct the first day of the NEXT month.

Try this (my date is current_date):
select date_trunc('month', current_date + '1 month'::interval) - '1 day'::interval

-------------------------------------------
Bastianello Luciano - MBS CP Development
Software Consultant - Apprentice Sorcerer
http://community.visual-basic.it/LucianoB/
e-mail: lbastianello@yahoo.it
MSN: cteniza@hotmail.com - ICQ: 209754422
AIM: lubastia - YAHOO lbastianello
-------------------------------------------







___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it

pgsql-general by date:

Previous
From: Sven Willenberger
Date:
Subject: Re: find last day of month
Next
From: Stephan Vollmer
Date:
Subject: Re: tsearch2: How to use different configurations for two