From: danmarc92 on
Does anybody have a good code for defining records to those within 1 year. We
have a field (closingdate) and so we need to show all records for up to 1
year after their closingdate.
Thanks
From: Eric Isaacs on
WHERE tablename.closingdate >= DATEADD(d, -366, CURRENT_TIMESTAMP)

-Eric Isaacs
From: Plamen Ratchev on
Here is one way:

SELECT <columns>
FROM Foo
WHERE closingdate >= DATEADD(YEAR, -1,
DATEADD(DAY, DATEDIFF(DAY, 0,
CURRENT_TIMESTAMP), 0));

HTH,

Plamen Ratchev
http://www.SQLStudio.com

From: danmarc92 on
Thanks for your help, the querues given do work but I actually need to
restrict the records to a year from the closingdate, not a year from current
date, does anyone know how to achieve this?.
Thanks

"Plamen Ratchev" wrote:

> Here is one way:
>
> SELECT <columns>
> FROM Foo
> WHERE closingdate >= DATEADD(YEAR, -1,
> DATEADD(DAY, DATEDIFF(DAY, 0,
> CURRENT_TIMESTAMP), 0));
>
> HTH,
>
> Plamen Ratchev
> http://www.SQLStudio.com
>
From: Plamen Ratchev on
Please provide table structure, inserts for sample data and expected
results. It is not clear from your notes what you really need.

HTH,

Plamen Ratchev
http://www.SQLStudio.com