title: Query to check duplicate record not working in 1 table but working for another table
body: <p>I have a table having a record for last month i.e. January 2018. The table format is as below:</p>
  
  <pre><code>D       ||  month  ||  year  ||  No of Sales
  Jan-18  ||   01    ||  2018  ||  231
  </code></pre>
  
  <p>Now, I am running a query to query to check for this record but, I am getting no output.</p>
  
  <pre><code>SELECT * FROM mytable 
  WHERE [year]=left(CONVERT(VARCHAR(8),DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)),112),4) 
  AND [month]=left(CONVERT(VARCHAR(8),DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)),1),2)
  </code></pre>
  
  <p>The expected output is:</p>
  
  <pre><code>D       ||  month  ||  year  ||  No of Sales
  Jan-18  ||   01    ||  2018  ||  231
  </code></pre>
  
  <p>This same query is working for another table which has the same structure as 'mytable'. What am I doing wrong here?</p>