Solved

Oracle 5 mins or ten minutes ago

Posted on 2013-01-30
4
1,545 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE 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 35

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

696 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