From: | "Luciano Bastianello " <lucianobastianello(at)yahoo(dot)it> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | R: find last day of month |
Date: | 2005-12-09 22:13:05 |
Message-ID: | 001d01c5fd0d$bb786940$220ba8c0@SFERA |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>> "Andrus Moor" <eetasoft(at)online(dot)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(at)yahoo(dot)it
MSN: cteniza(at)hotmail(dot)com - ICQ: 209754422
AIM: lubastia - YAHOO lbastianello
-------------------------------------------
___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Vollmer | 2005-12-09 23:10:22 | Re: tsearch2: How to use different configurations for two |
Previous Message | Sven Willenberger | 2005-12-09 21:27:42 | Re: find last day of month |