Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2008

    Unanswered: Currend date minus 3 months

    I have a colum which holdes MMYYYY (month and year) I need to query data to extract last 3 months data (MMYYYY between current date and current date minus 3 months)

    This ishow I did it in MS SQL
    MO_YR BETWEEN CAST(CONVERT(varchar(6),DATEADD(month,-3,GETDATE()),112)as int) AND cast(CONVERT(VARCHAR(6),getdate(),112) as int)

    Can some one tell me how to do itin ORACLE

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Oct 2002
    Cape Town, South Africa
    to_date(column, 'mmyyyy') between add_months(sysdate, -3) and sysdate
    sysdate = GETDATE()
    add_months = DATEADD() but is specific for adding months
    Also, would be a good idea to create a function based index on your column that converts it from varchar2 to date. This will speed up your query performance. In general, it's a real bad idea to store date information in varchar2 field.... you often don't get what you expected....

Posting Permissions

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