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

    Join Date
    Oct 2003
    Posts
    63
    Rep Power
    11

    subtracting 2 hours from date returned


    I am trying to write a query that will check

    where row_date >= sysdate - 2 hours

    what would the syntax look like for this?
    do i need to set the date format each time i run the query?

    thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    68
    Rep Power
    11
    where row_date >= sysdate - 2/24

    will do the job.

    Cheers,
    Dan
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    68
    Rep Power
    11
    BTW, Oracle 9i introduced several new date datatypes. One of them is the INTERVAL DAY TO SECOND datatype. Oracle introduced supporting functions for these new datatypes. Ones of them is the NUMTODSINTERVAL function.

    So, in 9i, the following is valid:
    WHERE row_date >= SYSDATE - NUMTODSINTERVAL(2, 'HOUR')

    Regards,
    Dan
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    63
    Rep Power
    11
    great...thanks for the reply.

IMN logo majestic logo threadwatch logo seochat tools logo