How to subtract two Dateformulas

Hello,

Here is what I am trying todo.

IF PayTerm.GET(“Sales Invoice Header”.“Payment Terms Code”) THEN BEGIN
TermDay:= PayTerm.“Due Date Calculation” - PayTerm.“Payment Offset”;
“Sales Invoice Header”.“Due Date”:=CALCDATE(’-TermDay’,“Sales Invoice Header”.“Due Date”);

I have created a new field in the payment terms table named Offset of type dateformula.

What I am trying to do is subtract this value from the Payment Terms Due Date Calculation and then use this value to calculate a new Due Date on the Sales Invoice. Any help would be appreciated.

Thanks

Hi Andrew,

I see you’ve made a second post that’s directly related to this one. It really helps cut down on redundant effort if you can keep questions to a single post/thread. http://dynamicsuser.net/forums/t/79369.aspx

I made a couple of suggestions in your other thread about the possible causes of your compile errors related to the CALCDATE function, and I see that the code here is quite different from the code in the other post. Since you’ve got what looks like typos in the other post, can I assume that you’re typing your code into your post and not copy/pasting it?

I think your hiccup here is related to your syntax on the CALCDATE function. The first argument either needs to be a datefilter data type, or a text string that is properly constructed to represent a valid date expression, following the syntax for building that expression according to the information in the CALCDATE help page. The expression you’ve got in your command looks wrong. First of all you’re using what looks like an integer value (the variable TermDay, which looks like an integer), then you’re encasing the name of that variable with single quote marks, which turns it into a literal, which, in this case, will certainly not work. The word TermDate is certainly not a valid date expression for the purposes of the CALCDATE function.

Hope that helps.