I have a statement…
if (lastInvoice.Invoice_Date < DateTime.Now.AddMonths(-12))
This checks the date on the Invoice, if it is less than 12 months ago I.E anything before Jan 2012, proceed with the code.
So instead of dateTime.Now.AddMonths(-12)) I want to say 6 months from the date on the invoice
I’ve tried…
if (lastInvoice.Invoice_Date < lastInvoice.Invoice_Date.AddMonths(-0-worksite.Number_of_Months))
Also tried without the (-0) and just had it as (0) but need the – for the expression.
Anyway it’s not returning what it should be. What am I doing wrong?
lastInvoice.Invoice_Datewill never be less thanlastInvoice.Invoice_Date.AddMonths(-anything).This should work for you:
If that isn’t giving you the correct answer, I’d use the debugger to confirm that worksite.Number_of_Months is actually what you expect it to be.