Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

selecting all records 14 days from the current date

I am trying to get all records that have a date not further than 14 days from the current date.

Today’s date is 12/7/2021.

When I run the following:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

select sysdate + 14 from dual

I get the following results:

12/21/2021 9:16:25 PM

Therefore, I should not be getting any records past the above date.

The column I am looking at is eta. Here is the query:

select
  full_name
  eta
from table
where eta > sysdate + 14

But when I run that query, I am getting dates as far out as in April and May.

How do I correct this?

>Solution :

All you are doing with where eta > sysdate + 14 is asking for records with an eta greater than 14 days from current database date. What you want is a between:

select
  full_name
  eta
from table
where eta between sysdate and sysdate + 14

This will give you any record with an eta between today and 14 days from now.

If you want records up to 14 days into the future, regardless of a lower bound, then you want:

select
  full_name
  eta
from table
where eta <= sysdate + 14
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading