question

technette avatar image
technette asked

Date within the last 5 years

Hi! I'm trying to show data with transaction date within the last 5 years. The following isn't working even when I select the column converted to datetime. TRANSACTION_DATE date
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
This web site runs on voting. Please indicate all helpful answers by clicking on the thumbs up next to those answers. If any one answer lead to a solution, please indicate this by clicking on the check mark next to that answer.
0 Likes 0 ·
dbaty avatar image
dbaty answered
TRANSACTION_DATE >= DATEADD(year, -5, GETDATE())
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Squirrel avatar image
Squirrel answered
if you want from 1st Jan 5 years ago DATEADD(year, DATEDIFF(year, 0, GETDATE()) - 5, 0) if you want 5 years ago today DATEADD(YEAR, -5, DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0))
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.