Solved

Oracle 5 mins or ten minutes ago

Posted on 2013-01-30
4
1,183 Views
Last Modified: 2013-02-01
What is the best way of finding whether my time stamp or date field in a table was 5 minutes ago?

Some people say timestamp, some say old fashioned date.

Thanks.

I needs to find if the date in the table was greater than five minutes ago. Maybe changed to ten minutes.
0
Comment
Question by:wilflife
4 Comments
 
LVL 37

Assisted Solution

by:Gerwin Jansen
Gerwin Jansen earned 125 total points
ID: 38834936
select fields from table where some_date_field > sysdate- 5/1440;

select fields from table where some_date_field > sysdate- 10/1440;
0
 
LVL 34

Assisted Solution

by:johnsone
johnsone earned 125 total points
ID: 38835316
What is the data type of the column?  Both DATE and TIMESTAMP are valid data types and they are different.

What is posted by  gerwinjansen will work with DATE data types.  If the column is a TIMESTAMP, it will work, however you will lose the precision of the TIMESTAMP data type.

If you change to the interval syntax, it should work with both data types and you would not lose the TIMESTAMP precision.

select fields from table where some_date_field > sysdate- interval '5' minute;

select fields from table where some_date_field > sysdate- interval '10' minute;
0
 
LVL 23

Assisted Solution

by:David
David earned 125 total points
ID: 38835438
johnsone has a good solution; my short add is to address the two methods.  THE TIMESTAMP function will mask down into the sub-seconds, whereas DATE takes it down to the second.

I chuckle at the "old-fashioned" adjective.  Why in my day, we only had hours........
0
 
LVL 32

Accepted Solution

by:
awking00 earned 125 total points
ID: 38835772
Are you looking for if the field value represents a time within the last 5 (or 10) minutes or if it was earlier than that?
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now