How to get id for dates

Table 1

id dates 01 23/02/2011 02 24/04/2011 03 26/08/2011 ... 

I want to select an identifier from table1 if dates are exceeded 6 months.

Expected result from tabl1

date id

 01 23/02/2011 'Dates is older than 6 month 02 24/04/2011 'Dates is older than 6 month 

How to make a request

Help required on request

+4
source share
2 answers
 select id, dates from Table1 where dates < dateadd(month, -6, getdate()) 
+5
source

select id from table1 where datediff(m, dates, getdate()) >= 6

+1
source

Source: https://habr.com/ru/post/1385773/


All Articles