title: select A where A < B in LINQ
body: <p>so using LINQ attempting to compare 2 values in the DB and select where the date is less than exactly a year today...so anything between 24/1/12 &amp; 24/1/13 will be selected.</p>
  
  <p>So i've got...</p>
  
  <pre><code>  var selectedObject =
              (from workstation in db.Work_Station
               join invoice in db.Invoices on workstation.id equals invoice.Site_Id
               where InvoiceDate &lt; DateTime.Now.AddYears(-1)
               select workstation).Distinct().ToList();
  </code></pre>
  
  <p>this is producing a list but its not correct.
  I've been playing about with the add years but can't seem to get it..
  Anyone have any ideas?
  Thank You</p>
  
  <hr>
  
  <p>EDIT:
  Hey everyone thank you for the quick response...i actually made a slight mistake, I want to return the value which has an invoice date of greater than exactly a year today.....So anything dated &lt;= 24/1/12 will be returned.  i have used ur suggestions to use...</p>
  
  <p>DateTime OneYearAgo = DateTime.Now.AddYears(-1);</p>
  
  <pre><code>    var selectedObject  =
          (from workstation in db.Work_Station
           join invoice in db.Invoices on workstation.id equals invoice.Site_Id
            where InvoiceDate &lt;= OneYearAgo
           select workstation).Distinct().ToList();
  </code></pre>
  
  <p>This returns a number of invoices...some of which are before the 23/1/12 and some of which are after.</p>
  
  <p>Iv tried changing to where CurrentInvoiceDate >= OneYearAgo, which should return any dated between now and one year ago, but nothing is returned...what am i doing wrong? please advise...thank you</p>