SHSH_123
SHSH_123

Reputation: 59

SQL Query to include future dated records

per_all_assignments_m is date effective and has the following sample data -

effective_start_date                effective_end_date                  ASG_Name
01-01-2020                              31-12-4712                      Sam
02-03-2020                              31-12-4712                      Maz
08-08-2020                              31-12-4712                      Fis
07-01-2020                              20-02-2020                      Max

When i use the below query it gives me the output as of today -

select ASG_Name from per_all_assignments_m
where trunc(sysdate) between effective_start_date and effective_end_date

This gives me the output-

effective_start_date                effective_end_date                  ASG_Name
01-01-2020                              31-12-4712                      Sam
02-03-2020                              31-12-4712                      Maz

How can i modify it in a way that it also includes data i.e. >=trunc(sysdate) i.e. the output should look like -

effective_start_date                effective_end_date                  ASG_Name
01-01-2020                              31-12-4712                      Sam
02-03-2020                              31-12-4712                      Maz
08-08-2020                              31-12-4712                      Fis

Upvotes: 0

Views: 183

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270513

You seem to want a simple comparison on the end date:

select ASG_Name
from per_all_assignments_m
where effective_end_date > trunc(sysdate) 

Upvotes: 1

Related Questions