Adding Days to Today and Using In Comparison

I am trying convert a Post-Processing BPM on QuoteAsm.ChangeOpMtlReqQty method. Whena new material is added to a quoteline method, I want to look at a future supplier price list for the cost. Price lists would be entered for 1, 2, or 3 months out. I am trying to use DateTime.Today.AddDays(28) in the C# code for searching the Supplier Part table but keep getting an exception.

What am I doing wrong. Cose is below and Exception follows.

//Name: UpdateUnitCost
//BO: QuoteAsm
//Method: ChangeOpMtlReqQty
//Type: Post-Processing
//
//Converted from ABL to C# 08/29/2019 MLW


var NewQM = (from NQMrow in ttQuoteMtl
             select NQMrow).ToList();

foreach(var QMIter in NewQM)
  {
    var MatchPart = (from UOMrow in Db.PartUOM
                     where UOMrow.PartNum == QMIter.PartNum && UOMrow.UOMCode == QMIter.IUM
                     select UOMrow).FirstOrDefault();
    
  if(MatchPart != null)
    {
    
    var MatchVPart = (from MVProw in Db.VendPart
                      where MVProw.PartNum == QMIter.PartNum && MVProw.VendorNum == 869 && MVProw.EffectiveDate <= DateTime.Today.AddDays(28) && MVProw.ExpirationDate >= DateTime.Today.AddDays(28)
                       select MVProw).FirstOrDefault();
    if(MatchVPart != null)
      {
          QMIter.EstUnitCost = MatchVPart.BaseUnitPrice / MatchPart.ConvFactor;
      }
    }
  }

Try the same but using datetime variable with the added days instead of adding then in your where clause.

DateTime FutDate = DateTime.Today.AddDays(28);
var MatchVPart = (from MVProw in Db.VendPart
                      where MVProw.PartNum == QMIter.PartNum && MVProw.VendorNum == 869 && MVProw.EffectiveDate <= FutDate && MVProw.ExpirationDate >= FutDate
                       select MVProw).FirstOrDefault();

Pierre

Thanks Pierre.

That worked.