Avatar of vbnetcoder
vbnetcoder
 asked on

and / or logic in where clause

how would I update the code to grab: Effective or Term within the last 7 days OR last update within last 7 days with effective or term date prior to the last 7 days?

WHERE ek.OrderId = 'rty5465464'

      AND (
              ek.termdate
      BETWEEN GETDATE() - 7 AND GETDATE()
              OR ek.effdate
      BETWEEN GETDATE() - 7 AND GETDATE()
	  OR
	          ek.lastupdate
      BETWEEN GETDATE() - 7 AND GETDATE()

Open in new window

* T-SQLMicrosoft SQL Server

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
vbnetcoder

ASKER
There are dates that look like this:
2017-11-01 00:00:00
vbnetcoder

ASKER
It looks like your code is returning values where term and effective date is null
vbnetcoder

ASKER
actually not. I was wrong about the nulls
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Pawan Kumar

can you pls provide few input rows and the expected output.
vbnetcoder

ASKER
ty
Bill Prew

Welcome.


»bp
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.