How to add '-' in DateFormula Field?

[?] Hi. I have the dateFormula field (for example 2W). When I use Date=CALCDATE(DateFormula,SomeDate) : Date = SomeDate + 2W So I need to minus 2W from SomeDate: Date = SomeDate - 2W How to do this?

Hello, yoy may write “SomeDate-1M+2W”. “SomeDate” must be acceptable for this type of expressions. I mean, for instance, “SomeDate:=‘CD’” (‘CM’, ‘CQ’ and so on).

Online help:

quote:


Using Date Formulas By using date formulas in Navision Attain, you can tell the program how to calculate dates. You can enter date formulas in various date calculation fields and in recurring frequency fields in recurring journals. Here are some examples of how date formulas can be used: The date formula in the recurring frequency field in recurring journals determines how often the entry on the journal line will be posted. The date formula in the Grace Period field for a specified reminder level determines the period of time that must pass from the due date (or from the date of the previous reminder) before a reminder will be created. The date formula in the Due Date Calculation field determines how the program calculates the due date on the reminder. The date calculation formula can contain a maximum of 20 characters, both numbers and letters. You can use the following letters, which are abbreviations for time specifications: C Current D Day(s) W Week(s) M Month(s) Q Quarter(s) Y Year(s) You can construct a date formula in three ways: Current plus a time unit. For example: CW Current week CM Current month A number and a time unit. A number cannot be larger than 9999. For example: 10D 10 days from today 2W 2 weeks from today A time unit and a number. For example: D10 The next 10th day of a month WD4 The next 4th day of a week (Thursday) You can combine these three forms as needed. For example: CM+10D Current month + 10 days You can use a minus sign to indicate a date in the past. For example: -1Y 1 year ago from today


-2W in your case.

Hi again. I’ve solve my problem this way: Text := FORMAT(DateFormula); Text := ‘-’ + Text; Date := CALCDATE(Text,SomeDate);

Yes also “SomeDate-14” should give the result. Best regards, Anthony

quote:


Originally posted by kopyurff
Yes also “SomeDate-14” should give the result.


The problem is that DateFormula cant convert to Text without FORMAT

did you try STRSUBSTNO ? it is generally a"cleaner" solution.

quote:


Originally posted by David Singleton
did you try STRSUBSTNO ? it is generally a"cleaner" solution.


No, I did not. [:)] May be you can say how to do it?

Date := CALCDATE(strsubstno('-%1',DateFormula),SomeDate);

fyi be aware that ‘-’ in front of ‘C’ indicates the begining of the period, instead of the end.