#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Data for dates between sysdate and sysdate-30 days


    Hi there,

    I am new to oracle and have an issue with selecting data from a table on date criteria.

    select * from table1 t where
    t.DT BETWEEN TO_DATE(sysdate-1,'dd/mm/yyyy') AND sysdate

    my understanding is that this should give me the data for just one day. but it is not.
    What I want is, data for last 30days from today. So can someone please help me with this.

    thank you.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,785
    Rep Power
    348
    There is no need to apply to_date() on sysdate, because sysdate is already a date. to_date() converts a character string into a date.

    Try this:
    Code:
    select * 
    from table1 t 
    where t.DT BETWEEN sysdate-1 AND sysdate
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    2
    Rep Power
    0
    oh thank you..that helped.....

IMN logo majestic logo threadwatch logo seochat tools logo