We help IT Professionals succeed at work.

Checking Date is Over 3 days old

rito1
rito1 asked
on
212 Views
Last Modified: 2010-04-21
Hi All
I have the following WHERE clause. I have been asked to modify it so that it doesn't just return dates that are older than today's date but rather over 3 days ago.

WHERE callbackdate < CONVERT(varchar, GETDATE(), 112)

To give an example...

My WHERE clause wouldn't pick up records that have a callbackdate of yesterday but rather 3rd July (today being the 7th)

Can anyone provide me with the syntax to achieve this?

Many thanks,

Rit
Comment
Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
what is the data type of the column callbackdate?
in case it is NOT datetime, but varchar, what is the format in that column?
CERTIFIED EXPERT
Awarded 2008
Awarded 2008

Commented:
try this:

where callbackdate < dateadd(dd, -3, getdate())
Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Awarded 2008
Awarded 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
thanks both, angelIII, its a datetime(8).

Rit
CERTIFIED EXPERT
Awarded 2008
Awarded 2008

Commented:
if its datetime, then you're all good....

Author

Commented:
thanks Both. I have gone with angellll's..

WHERE (callbackdate < CONVERT(varchar, DATEADD(DAY, - 3, GETDATE()), 112)) as 101 is not the correct format... but you are not to know that though.

Author

Commented:
thanks again.
CERTIFIED EXPERT
Awarded 2008
Awarded 2008

Commented:
Im surprised that there was no split on this one....one of those days I guess.  :)
CERTIFIED EXPERT
Awarded 2008
Awarded 2008

Commented:
whoops..spoke too soon.  glad you got it working.  8)

Author

Commented:
You 2 are always so helpful.

thanks so much!
Rit

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.