Re: Date function

From: Jurij Modic <jurij.modic_at_mf.sigov.mail.si>
Date: 1998/04/07
Message-ID: <352a32ef.25156799_at_www.sigov.si>#1/1


On Tue, 7 Apr 1998 13:36:41 +0200, "Victor Zwimpfer" <vzwimpfer_at_scope.ch> wrote:

>Hi
>
>Is there a Date function that returns me the maximum number of days of the
>month, if i know the month and the year.
>Example:
>
>March: 31 days
>April: 30 days
>February: 28/29 days, dependign if it is a leap year or not.
>
>Thank you
>Victor
>vzwimpfer_at_scope.ch

Use SQL function LAST_DAY(<your_date>), which returns the date of the last day of the month, containing <your_date>. You can use the format masks to format the results the way you want them.

Examples:

SQL> SELECT sysdate FROM dual;

SYSDATE



07-APR-98 SQL> SELECT TO_CHAR(LAST_DAY(sysdate),'DD') last_day FROM dual;

LAST_DAY



30

SQL> SELECT TO_CHAR(LAST_DAY('01-FEB-95'),'DD') last_day FROM dual;

LAST_DAY



28

SQL> SELECT TO_CHAR(LAST_DAY('01-FEB-96'),'DD') last_day FROM dual;

LAST_DAY



29

Regards,


Jurij Modic                             Republic of Slovenia
jurij.modic_at_mf.sigov.mail.si		Ministry of Finance
============================================================
The above opinions are mine and do not represent any official standpoints of my employer Received on Tue Apr 07 1998 - 00:00:00 CEST

Original text of this message