R: find last day of month

Поиск
Список
Период
Сортировка
От Luciano Bastianello
Тема R: find last day of month
Дата
Msg-id 001d01c5fd0d$bb786940$220ba8c0@SFERA
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Sven Willenberger
Дата:
Сообщение: Re: find last day of month
Следующее
От: Stephan Vollmer
Дата:
Сообщение: Re: tsearch2: How to use different configurations for two