views:

46

answers:

2

Howdy,

this should be a fairly simple question but I know very little about SQL. I have a database which has the following fields:

client_id, scheduled_amount, deposit_amount, message_code_id, note_text, system_date

now I wish to select all the records that are less than 1 year old from when the sql statement is run. I know I should use DateDiff, anyone got any ideas?

Thanks

+6  A: 
select *
from MyTable
where MyDate > DATEADD(year, -1, GetDate())
RedFilter
+1 for sargability.
Martin Smith
+1 to your comment Martin, for your use of the word Sargability
Patrick McDonald
+1  A: 

TRY

SELECT * FROM TABLE_NAME WHERE SYSTEM_DATE > DATEADD(YYYY, -1, GETDATE())

(UNTESTED)

STEVE