Date Calc error

mb6606mb6606 Member Posts: 30
Can anyone help with the following Date Calc? I get a date time unit error message on the Calcdate line thanks in advance.

startd and endd are variable date field from user Option Request form

FOR Y:=1 TO 12 DO BEGIN
IF startd<>0D THEN BEGIN
sd[Y] := STRSUBSTNO('-%1M+startd',Y);
ed[Y] := STRSUBSTNO('-%1M+endd',Y);
END;

sd2[Y]:= CALCDATE(sd[Y]);
ed2[Y]:= CALCDATE(ed[Y]);
END;

Comments

  • jversusjjversusj Member Posts: 489
    keep this in mind when using CALCDATE:
    NewDate := CALCDATE(DateExpression [, Date])
    NewDate
    Data type: date
    The date the system computes from the reference date and the date expression.

    DateExpression
    Data type: text, code or dateformula
    The date expression can be any length. The system interprets the string from left to right, one subexpression at a time.

    Date
    Data type: date
    Use this optional parameter to define a reference date. The default is the current system date.
    kind of fell into this...
  • mb6606mb6606 Member Posts: 30
    Yes I solved before you post.
    Thanks anyway for your help!!
  • kinekine Member Posts: 12,562
    mb6606 wrote:
    Can anyone help with the following Date Calc? I get a date time unit error message on the Calcdate line thanks in advance.

    startd and endd are variable date field from user Option Request form

    FOR Y:=1 TO 12 DO BEGIN
    IF startd<>0D THEN BEGIN
    sd[Y] := STRSUBSTNO('-%1M+startd',Y);
    ed[Y] := STRSUBSTNO('-%1M+endd',Y);
    END;

    sd2[Y]:= CALCDATE(sd[Y]);
    ed2[Y]:= CALCDATE(ed[Y]);
    END;

    Do not forget to add '<' and '>' around the string before passing it to the CALCDATE, else you will have problems when you switch client into another language.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.