Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Posts
    5

    Unanswered: Syntax Help for Date Format.

    Greetings. I've want to to a Between statement where I keep getting oracle Syntax errors.

    S1.ROW_ID = S_Srv_Req.ROW_ID) >= TO_DATE(TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'MM') || '-01-' ||TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'YYYY'), 'MM-DD-YYYY')

    This is WHAT I tried: I was going for between July 2005 and July 2007

    S1.ROW_ID = S_Srv_Req.ROW_ID) BETWEEN( TO_DATE('2005/07/01','yyyy/mm/dd') AND <= TO_DATE('2007/07/01','yyyy/mm/dd')

    and S1.ROW_ID = S_Srv_Req.ROW_ID) >= TO_DATE('2005/07/01','yyyy/mm/dd') AND <= TO_DATE('2007/07/01','yyyy/mm/dd')

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    I must admit I don't understand what this means:
    Code:
    S1.ROW_ID = S_Srv_Req.ROW_ID)
    This is an example based on the Scott's EMP table - I want to select all employees who are employed between September 1981 and December 1981; apply such a logic to your problem:
    Code:
    SELECT * FROM EMP
    WHERE hiredate BETWEEN TO_DATE('09.1981', 'mm.yyyy') 
                       AND TO_DATE('12.1981', 'mm.yyyy');

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Talking



    For the first part of your statement where you subtract the twelve months you could try this:
    Code:
    ... >= TRUNC(ADD_MONTHS(SYSDATE,-12),'MONTH')

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

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