Peter_07
Peter_07

Reputation: 117

SQL date within a specific range

In SQL Server, and if we have 2 dates, how to return those records having the first date within 6 months before the second date. For example in the following table:

enter image description here

The output will be the highlighted rows in green.

Please note that I'm not trying to calculate the difference between a date from my table and te current date.

Upvotes: 0

Views: 70

Answers (1)

RoMEoMusTDiE
RoMEoMusTDiE

Reputation: 4824

DATEDIFF

select date1,date2
from mytable
where datediff(month,date1,date2) < 7

Upvotes: 1

Related Questions