Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    65

    Question Unanswered: last_month_date or something similar in Sybase

    Hi,
    I was wondering if anybody knew something in sybase or some code that gave me the last month end date from a table. I kno oracle has last_day function i believe.

    I also wanted to kno if there was a way of doing something to get a query back between 2 dates. Lets say i did getdate()-1 and getdate()-3.
    and getdate was dec... i would get sept oct and nov data.
    But it should work also no matter what month. lets say i did this select next year feb ... i should get jan04 dec03 nov03

    I have tried a few i keep getting data that isnt right ... hope somebody can help with something

    Thanks in advance.

  2. #2
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    Someone asked same just a few days back.

    http://www.dbforums.com/t973990.html

  3. #3
    Join Date
    Nov 2003
    Posts
    65
    thank for the reply. i will try that solution but i think that solution gives u the number of days in a month. my problem is getting the previous month's end date. so if i ran a query this month i would calculate the novembers last day which is 30th.


    Originally posted by willy_and_the_ci
    Someone asked same just a few days back.

    http://www.dbforums.com/t973990.html

  4. #4
    Join Date
    Nov 2003
    Posts
    65

    Cool RE: last_month_date or something similar in Sybase

    That linked help alot. Thanks again. Here is the solution i used in my query:

    where datediff(mm, convert(varchar(10), getdate(), 112), convert(varchar(10), ex_date, 112)) >= -3
    and datediff(mm, convert(varchar(10), getdate(), 112), convert(varchar(10), ex_date, 112)) <= -1

    this gave me all the data between nov03 oct03 sept03 which is what i need to run on a regular basis. I tested for feb04 and got the right data for jan04, dec03, nov03.

    Thanks.

    Originally posted by willy_and_the_ci
    Someone asked same just a few days back.

    http://www.dbforums.com/t973990.html

Posting Permissions

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