Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    Atlanta, GA
    Posts
    21

    Unanswered: Query - with date in where clause

    Hi,

    I'm trying to run a query to return values from the 10th of last month to the 9th of this month, whenever it is ran. I tried add_months but it is giving me records from a month ago e.g.

    select name,dept,age
    from mytable
    where hire_date >= add_months(sysdate,-1)

    I need the query to return value from 10th of last month to 9th of this month no matter when it is ran.Even when the query is ran on the 12th

    Thanks
    It pays to share!

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    PHP Code:
    select namedeptage
    from mytable
    where hire_date between
      last_day
    (add_months(sysdate, -2)) + 10
      
    and 
      
    last_day(add_months(sysdate, -1)) + 9


Posting Permissions

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