Date Formula to Integer

fmhiguefmhigue Member Posts: 290
edited 2004-09-07 in Navision Attain
I got the following code

EVALUATE(LeadTime,FORMAT(USItem."Lead Time Calculation")+'+4D')

How can I change this to Integer?

Does any one of you have a manual on C/AL commands?

Thank you

Comments

  • kinekine Member Posts: 12,562
    F1 in C/AL symbol menu doesn't help?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • StephenGStephenG Member Posts: 99
    Hi

    You could try this.
    Declare a Variable if Type Integer eg. IntLeadTime
    Then change the original Evaluate to this
    EVALUATE(IntLeadTime,FORMAT(USItem."Lead Time Calculation")+'+4D')
    Or You could just do
    EVALUATE(IntLeadTime,FORMAT(LeadTime))
    Answer the question and wait for the answer.
  • jreynoldsjreynolds Member Posts: 175
    A date formula does not convert to an integer. What integer would you want 'CM + 4D' to convert to? The "value" of a date formula depends on the specific date the formula is applied to. You could pick an arbitrary date (e.g. TODAY, WORKDATE), use CALCDATE, and then subtract the original date from the result to arrive at an integer number of days. But the result will be dependent upon the arbitrary date you pick.
  • fmhiguefmhigue Member Posts: 290
    Jreynolds:

    Well then If i can't convert dateformula to integer. How can I add more days to initial value?

    EVALUATE(LeadTime,FORMAT(USItem."Lead Time Calculation")+'+4D')

    This is the line I have. So then I will prefer to add 4 days to inial value.
  • SavatageSavatage Member Posts: 7,142
    Fun Facts
    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:

    1. Current plus a time unit. For example:

    CW - Current Week
    CM - Current Month

    2. 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

    3. 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
  • i4tosti4tost Member Posts: 208
    You can always do arithmetic operations like LeadTime := LeadTime + 4. Also You can find difference like
    IntegerValue := CALCDATE(YourDateFormula,TODAY) - TODAY
  • fmhiguefmhigue Member Posts: 290
    i4tost it does not work like that

    I am getting the following error message:

    Type conversion is not possible because 1 of the operators contains an invalid type
    DateFormula + Integer
  • andreofandreof Member Posts: 133
    Show us your code line


    André
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • fmhiguefmhigue Member Posts: 290
    This is my actual code

    IF CompanyInformation."Country Code" = 'MX' THEN
    EVALUATE(LeadTime,FORMAT(USItem."Lead Time Calculation")+'+4D')
    ELSE
    LeadTime:=USItem."Lead Time Calculation";

    This way I get for example 14D + 4D

    I tried the code LeadTime:=USItem."Lead Time Calculation"+4;
    but I get the error message I previously said.

    LeadTime: DateFormula
    Thank you a lot
  • i4tosti4tost Member Posts: 208
    OK, i think i did not understood what you asked :)
    In this case you can do like this
    EVALUATE(LeadTime,FORMAT(USItem."Lead Time Calculation") + STRSUBSTNO(TextConstant,YourIntegerNumber))

    TextConstant in English must be +%1D, in other language it can be differ. System instead of %1 will place YourIntegerNumber
Sign In or Register to comment.