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
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
try this:
where callbackdate < dateadd(dd, -3, getdate())
where callbackdate < dateadd(dd, -3, getdate())
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks both, angelIII, its a datetime(8).
Rit
Rit
if its datetime, then you're all good....
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.
WHERE (callbackdate < CONVERT(varchar, DATEADD(DAY, - 3, GETDATE()), 112)) as 101 is not the correct format... but you are not to know that though.
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)
ASKER
You 2 are always so helpful.
thanks so much!
Rit
thanks so much!
Rit
in case it is NOT datetime, but varchar, what is the format in that column?