How to cancatenate date formula

roshiniroshini Member Posts: 122
Hi Nav Experts!

How to concatenate field +M

Example: '1M'

paymentdate is a field in customer table.

I want to use the formula '1M' like my filed(paymentdate)+M, how to write code?

My code as follows:

dategrace:= paymentdate;

date1:='dategrace+M'

payment2:= CALCDATE(date1, MonthStartDate);


but it is throwing error.

Comments

  • garakgarak Member Posts: 3,263
    Try this.
    Name	DataType	Subtype	Length
    NewDate	Date		
    BaseDate	Date		
    
    BaseDate := 12072008D;
    NewDate := calcdate('<1M>',BaseDate);
    message(format(NewDate));
    

    Regards
    Do you make it right, it works too!
  • pri_1_ranjanpri_1_ranjan Member Posts: 67
    I hope dategrace and date 1 have datetype as 'text' ; and paymentdate as integer. MonthStartDate and Payment2 as Date.

    you could use following code snippet might help, if it suits u

    dategrace:= format(paymentdate);

    date1:=dategrace+'M'

    payment2:= CALCDATE(date1, MonthStartDate);

    hope this helps
    /PDR
  • David_SingletonDavid_Singleton Member Posts: 5,479
    garak wrote:
    Try this.
    Name	DataType	Subtype	Length
    NewDate	Date		
    BaseDate	Date		
    
    BaseDate := 12072008D;
    NewDate := calcdate('<1M>',BaseDate);
    message(format(NewDate));
    

    Regards

    Maybe I am missing something, but I can not see how this in any way addresses the question asked?
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    roshini wrote:
    Hi Nav Experts!

    How to concatenate field +M

    Example: '1M'

    paymentdate is a field in customer table.

    I want to use the formula '1M' like my filed(paymentdate)+M, how to write code?

    My code as follows:

    dategrace:= paymentdate;

    date1:='dategrace+M'

    payment2:= CALCDATE(date1, MonthStartDate);


    but it is throwing error.

    Although you some how "forgot" to tell us what the error was. I guess it is a type mismatch. The problem being here that you have three different variables types, Integer, Text and DateFormula. So you need to use the format and evaluate functions to solve this. I don't have time to try it out, bu somethign like :
    OK := evaluate(MyNewFormula,strsubstno('%1M',DaysOfGrace));
    
    David Singleton
  • ara3nara3n Member Posts: 9,256
    here is an example on tips and tricks

    viewtopic.php?f=5&t=13982
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • garakgarak Member Posts: 3,263
    Because i understand it so, that he will calculate the payment2 date based on payment date field + 1 Month based on the 1. of the currmonth.

    Or need he a concatonation of dateformulas?

    Regards
    Do you make it right, it works too!
  • roshiniroshini Member Posts: 122
    Thanks a lot for the suggestions! I got much idea about date formula use.

    Great!!

    My purpose solved with the solutions of Mr.David Singleton/Mr. pri_1_ranjan.

    I struggled to get that value,Thanks a lot.....
Sign In or Register to comment.