id date records not available and get last 12 months data in mssql code example Example: sql where last 12 months select Dateadd(Month, -12, GETDATE())