R: find last day of month
"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