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.
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.
Not sure (I don’t use Oracle), but if row_date is a date type in Oracle, you could try something like:
SELECT *
FROM tablename
WHERE row_date >= SYSDATE-2/24
Otherwise, if it is a char type, you would want something like:
SELECT *
FROM tablename
WHERE TO_DATE(row_date, ‘DD-MON-YY’) >= SYSDATE-2/24
Hope that helps!
– Jill
where row_date >= sysdate - interval ‘2’ hour
i know it looks weird having that 2 in quotes, but that’s the format
Good thing I don’t use Oracle, eh?!
THAT’s the command I was searching around for…didn’t have my Oracle Bible with me, though. ![]()
Just for curiosity’s sake, what is the difference between the SYSDATE - 2/24 versus the SYSDATE - interval ‘2’ hour ?
Everything I’ve researched has show the SYSDATE - 2/24…
that’s a really good question
i trust the interval arithmetic expression to give the correct time, whereas sysdate-2/24 is a date minus a fraction, and who knows if that will come up with the same datetime result
i wish i had oracle, this would be such a simple test to run…
Thank you both for the feedback…i appreciate it
mike
i don’t have any oracle books, i just use their online docs
![]()
You must have better luck than me. I have the worst time trying to navigate through those docs…it’s usually just faster to pull the book out.