Q

Working with dates in Oracle

I have a table that contains two dates, "vis_dt1" and "vis_dt2." I want to find all "vis_dt2 dates" that fall outside a certain window, e.g. 144 - 260 days after "vis_dt1", but including "vis_dt1". I know Oracle gives me the days between, but how do I adjust for the first day? Is there a general rule for date arithmetic like this?
I think in your "where clause" specifying the following condition to address your requirement:

TRUNC(vis_dt2) NOT BETWEEN trunc(visdt1+144) and trunc(visdt1+260)
AND trunc(vis_dt2) >= trunc(vis_dt1)

This was first published in January 2005

Dig deeper on Using Oracle PL-SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close