Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Posts
    47

    Question Unanswered: using date function

    how can i get the last day of the month using date function. for example the query must return "31 st october" as a result if i give the month and year.

    thanks in advance

  2. #2
    Join Date
    Apr 2003
    Location
    Jagdishpur
    Posts
    146
    Hi,
    This is pretty simple and can be done by a simple function called LAST_DAY which accept DATE data-type as a parameter & return as DATE data-type.

    Check this out:
    select last_day(sysdate) from dual;

    Or, for your case as you indicated, it is done like this:
    select last_day(to_date('10/2004','mm/yyyy')) "Last Date of Month" from dual;

    You can now put your desired format to display the date.

    Hope that helps.

    Regards,
    Kamesh Rastogi
    - KR

  3. #3
    Join Date
    May 2004
    Location
    Dominican Republic
    Posts
    721
    And to get "31st of October", you would just:
    Code:
    select to_char( last_day( to_date('10/2004','mm/yyyy') ), 'DDth "of" Month' ) from dual

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •