Requirement is that, we need records for below 'production_date':
today='2015-08-06 00:00:00.000'.
As of today, production_date's in JULY only.
And in SEPT, production_date's from JULY AND AUGUST.
In OCT, production_date's from JULY, AUGUST and SEPT ..and so on..
BUT once in JAN 2016, production_date's from last 6 months only.
This means from FEB 2016, productions_date's from AUG 2015 TO JAN 2016
additonal info:
Production_date is a date column. And i'm filtering records based on above condition.
I tried:
Production_Date > DATEADD(month, DATEDIFF(month, 0,DATEADD(MM,DATEDIFF(m,DATEADD(month, DATEDIFF(month, 0, GETDATE()),0),'2016-01-01 00:00:00.000')-6,GETDATE())), 0)
AND
Production_Date< DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0)
Please let me know how to go about gettting this in a query.