Reputation: 15321
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
Upvotes: 31
Views: 65851
Reputation: 31
TRY
SELECT * FROM TABLE_NAME WHERE SYSTEM_DATE > DATEADD(YYYY, -1, GETDATE())
(UNTESTED)
Upvotes: 3
Reputation: 171579
select *
from MyTable
where MyDate > DATEADD(year, -1, GetDate())
Upvotes: 73