ONYX
ONYX

Reputation: 5859

SQL Server Get Date Field if less than 3 month

I just need a where condition in my select statement where AddedDate is less than or within the 3 month backet. Like

Select * FROM My Table where AddedDate DateDiff of DateNow less than 3 months

Upvotes: 10

Views: 38899

Answers (3)

Diego
Diego

Reputation: 36156

not entirely sure that I understand but I think this is the function you need

where AddedDate >= dateadd(mm, -3,  getdate())

Upvotes: 1

Sir Crispalot
Sir Crispalot

Reputation: 4854

SELECT *
FROM   MyTable
WHERE  AddedDate >= DATEADD(month, -3, getdate())

Upvotes: 6

Curtis
Curtis

Reputation: 103388

Use DATEADD():

Select * FROM My Table where AddedDate>=DATEADD(m, -3, GETDATE())

Upvotes: 27

Related Questions