How to select data from sql that is older than 6 months?
datediff, sql
Solution
Instead of your `DateDiff` line, use:
AND (DateAdd(MM, -6, GetDate()) > SignOffDate)
Problem
I want to select some data from one table if a date from another table is at least 6 months before today. I tried going off of something like this: Select records from SQL Server if greater than 6 months but I get the error: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. Here is my way of approching this: ``` SELECT FCIF, [Date], [Desc] FROM tblFCIF WHERE tblFCIF.FCIF = (SELECT FCIFSignOff.FCIF FROM FCIFSignOff WHERE ID='12' AND (DateDiff(month,SignOffDate,GetDate()) > 0) ) ``` So this code withouth the last line selects everything with the ID, 12. I just need to get everything that is from 6+ months ago. ``` DATEDIFF(datepart,startdate,enddate) ``` when 'month' is in daypart it returns the difference in months.