Results 1 to 2 of 2

Thread: last_day function

  1. #1
    Chris Guest

    last_day function

    There is a date function in Oracle called last_day, to return the last day of the month of the date expressed in the function. This function doesn't exist in T-SQL - does anyone have any tricks I can use to get the same result, or knows of a function that will do it for me?

  2. #2
    Phil Simms Guest

    last_day function (reply)

    I admit this is a bit complicated looking but it works.

    SELECT Convert(datetime, Convert(varchar(2), MONTH(DATEADD(MM, +1, Getdate()))) + '-' + Convert(varchar(2), DAY('01-dec-2000&#39) + '-' + Convert(varchar(4), YEAR(DATEADD(MM, +1, Getdate())))) -1

    If you find something simpler please post it. I'd love to find something better myself.
    ------------
    Chris at 4/11/2002 4:17:30 AM

    There is a date function in Oracle called last_day, to return the last day of the month of the date expressed in the function. This function doesn't exist in T-SQL - does anyone have any tricks I can use to get the same result, or knows of a function that will do it for me?

Posting Permissions

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