Solved

Oracle 5 mins or ten minutes ago

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
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…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

691 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