Link to home
Start Free TrialLog in
Avatar of rito1
rito1

asked on

Checking Date is Over 3 days old

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
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

what is the data type of the column callbackdate?
in case it is NOT datetime, but varchar, what is the format in that column?
try this:

where callbackdate < dateadd(dd, -3, getdate())
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rito1
rito1

ASKER

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

Rit
if its datetime, then you're all good....
Avatar of rito1

ASKER

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.
Avatar of rito1

ASKER

thanks again.
Im surprised that there was no split on this one....one of those days I guess.  :)
whoops..spoke too soon.  glad you got it working.  8)
Avatar of rito1

ASKER

You 2 are always so helpful.

thanks so much!
Rit