Problem with first argument in CALCDATE function

poppinspoppins Member Posts: 647
edited 2012-08-13 in NAV Three Tier
Hi everyone,

The problem I am facing is with the following instruction(my page compiles but does not run):
MyDate := CALCDATE( "remainingTime", "Start Date");

When I look in the Source Table of the form, "remainingTime" is of type Integer...

What shall I do???

Answers

  • BeliasBelias Member Posts: 2,998
    you should hit F1 and read the help about calcdate:
    NewDate := CALCDATE(DateExpression [, Date])
    Parameters
    DateExpression
    Type: Text, Code, or DateFormula
    [...a lot more in the help...]
    as you can see, integer is not a valid parameter
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • poppinspoppins Member Posts: 647
    I know all that...
    The problem is that I am reviewing an old code...and I don't have the permission to change anything in the datatypes of the table fields...I was wondering if I can convert the integer value to a date...
  • David_SingletonDavid_Singleton Member Posts: 5,479
    What are you trying to do?
    David Singleton
  • poppinspoppins Member Posts: 647
    What are you trying to do?

    In fact, I am reviewing an old code in order to transform the forms into pages...
    This is one of the issues I encountered...
  • BeliasBelias Member Posts: 2,998
    you've opened another thread about how to convert integer to date. Let's continue on this one.
    well, if you know calcdate, you also know that it's not the function to convert integer to data ;)
    what kind of integers do you want to convert?
    what date is 234567890, for example?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • poppinspoppins Member Posts: 647
    I do know the CALCDATE() function, but maybe I didn't express myself well :wink:

    I was looking for a way to convert the integer value to a date before passing it to the CALCDATE function...The integer value expresses the number of the remaining days before starting a payment...

    I tried the FORMAT() function, and the errors disappeared, but I am not really sure about the results...I have to check with my manager...
  • BeliasBelias Member Posts: 2,998
    please post an example. It's not 100% clear, yet.

    if you have '12' in your field, what date should it become? today+12? some date field +12?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • poppinspoppins Member Posts: 647
    Belias wrote:
    please post an example. It's not 100% clear, yet.

    if you have '12' in your field, what date should it become? today+12? some date field +12?

    If I have '12' in my field, it should be added to another date field (a date in which the employee got the loan)
  • BeliasBelias Member Posts: 2,998
    The correct way to achieve your goal would be defining that field as dateformula instead of integer, so that the user can type 12D, or 1M etc. Of course, your users should be trained about it.

    By the way...it's an old customization with old data, so you can:
    - create another field of type dateformula to store the information
    - convert your integer field to date formula as follows and put the result in the new field
    - clear the data the old field
    - copy in a notepad the old field number
    - delete the old field
    - rename the new field with the number of the old one

    or you can use the "dirty way":

    In order to make that field a valid parameter you should format it like this.
    mydaysasdateformula := '<' + format(myinteger) + 'D>'
    
    which results in <12D> (brackets to make the formula "language independent")
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • poppinspoppins Member Posts: 647
    Thank you :D
  • BeliasBelias Member Posts: 2,998
    you're welcome.
    PS: test the modification on a test database, obviously...especially if you move the data (i recommend that solution, instead of the "dirty way")
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    poppins wrote:
    If I have '12' in my field, it should be added to another date field (a date in which the employee got the loan)

    Then try
    MyDate := "Start Date"+ "remainingTime";
    
    David Singleton
Sign In or Register to comment.