Solved

Oracle 5 mins or ten minutes ago

Posted on 2013-01-30
4
1,081 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 31

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

760 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

23 Experts available now in Live!

Get 1:1 Help Now