last dtae of the month

Поиск
Список
Период
Сортировка
От Rajesh nalankal
Тема last dtae of the month
Дата
Msg-id 20041003064137.18925.qmail@web61008.mail.yahoo.com
обсуждение исходный текст
Ответы Re: last dtae of the month  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-novice
hi every body
 
 
here is my function to get last day of the month. but it causes error while executing.
 
please help
 
/*
This function returns the last day of the given date's month.
-- Logic --
extract month and year from the given date
build a date of next month by concatnating these values and any day* ( 1- 28)
then substract the given day* from the concatnated date.
*/
declare
dteGivenDate date;
intGivenMonth integer;
intGivenYear integer;
intNextMonth integer;
dteLastDay date;
strTmp varchar;
dteTmp date;
begin
--dteGivenDate:='12-03-2004';
dteGivenDate:=$1;
intGivenYear:=date_part('year',timestamp dteGivenDate);
intGivenMonth:=date_part('month',timestamp dteGivenDate);
intNextMonth:=intGivenMonth + 1;
if intNextMonth >12 then
   intNextMonth:=1;
   intGivenYear:=intGivenYear+1;
end if;
strTmp:= intGivenYear || '-' || intNextMonth || '-' || '10'; -- here we can give any value insted of 10 ranging from (1-28)
dteTmp:= to_date(strTmp,'YYYY MM DD');
dteLastDay:= date dteTmp - 10;
return dteLastDay;
end;
 
 
 
****************
 
is there any other alternative to this function like  a builtin function like last_day ...
 
sincerely rajesh


Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Madhukar Gole"
Дата:
Сообщение: Help needed to set parameters in postgresql.conf
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: last dtae of the month