calculating date in NAV Classic Client

Dear Professionals,

I need a help in calculating dates. The scenario is:

in Warehouse Receipt Line - I need to add the fields:Current System Date (Work Date), Expiration Date & Days Due - Under (Over)

The computation would be:

Days Due - Under (Over) = Expiration Date - Current System Date

Current System Date Expiration Date Days Due - Under (Over)

3/8/2012 3/15/2012 7
3/9/2012 3/15/2012 6

And How can I import the work date in the field of Warehouse Receipt Line?

please help me out on how to do this. :slight_smile:

What did you try and what problem are you facing?

You have it right

Assuming [Days Due - Under (Over)] is an int

[Days Due - Under (Over)] = [Expiration Date] - WorkDate

You don’t need to import the workdate into the field of the Warehouse Receipt Lines. It is a system variable that is set to the current date unless the user changes it in thier client.

I hope that helps.

Hi Mohana,

I’d like to know the steps for that computation…

Hello Teresa,

My first date type for Days Due - Under (Over) is Date… but when I tried to change its type to Integer, I saved it and when I open the receipts from warehouse., it says:

"The definition of the field Days Due - Under (Over) was changed after the object was saved.

Old Type: Date

New Type: Integer "

I tried to delete and create a new field with an Integer Type but it says the same thing.,

I solved about this… now, my problem is., I don’t know the steps for the calculation of the due date

Hi Ms. Teresa,

there is no date in the variables.

Are you saying that you do not have the expiration date on the line?

There., I found the expiration date and Due date in the field

Now, I tried to put an expiration date then the other field of expiration date (un-editable) updated

Sample appeared:

Expiration Date Due Date

10/20/12 10/12/2012

Meaning, the Current date is the one reflecting on Due Date field there is no calculation…

Can you tell us what is your requirement exactly adn where and what did you do?

And there is nothing mentioned about Due Date in your first post…

I need to add this field in Warehouse Receipt Line

The computation would be:

Days Due - Under (Over) = Expiration Date - Current System Date

Current System Date Expiration Date Days Due - Under (Over)

3/8/2012 3/15/2012 7
3/9/2012 3/15/2012 6

Days Due & Expiration date is already in the table warehouse receipt line…

Now., as what I’ve said, the Days Due is not automatically computing according to the computation above.

I did not use any codes yet…

When do you want to calculate the Days Due?

while changing the Expiration Date or Current system date?

How is the value updating in Current System Date fields?

It’s while encoding the expiration date.

There is no current system date field in warehouse receipt line.

Then you have to Write below code in Table Expiration Date OnValidate Trigger

Days Due = Expiration Date - WorkDate;

I guess WorkDate will be always your system date…


I wrote this code

“Due Date” := “Expiration Date” - WorkDate;

There is an error:

“Type conversion is not possible because 1 of the operators contains an invalid type.”


The Difference between two dates will be an Integer…not Date…

May be you want to calculate the Due Date based on difference value of Expiration Date and WorkDate?

yes po

you have to have one integer variable(NoofDays)

NoofDays := Expirationdate - WorkDate;

DueDate := CALCDATE(FORMAT(NoOfDays)+‘D’,WORKDATE); // the workdate should be replaced with field on which you want to calculate…

Hi Mohana,

Thank you for the code. It worked! In

Due Date Field I put

“Due Date” := CALCDATE(FORMAT(NoofDays)+‘D’,“Expiration Date”);

And in NoOfDays

NoofDays := “Expiration Date” - WORKDATE;

It is now working, This is the sample output

Expiration Date NoofDays Due Date
3/22/2012 9 3/31/2012

But, upon putting the expiration date, I also have to put any value in the field of NoOfDays before it updates the Due Date but it also updates the NoOfDays even any value was inputted…

My question is., is there a code for them to be automatically updated upon putting the expiration date without hitting the NoOfDays?

You are confusing me…

Please explain clearly which field you want give input and which field you want to calculate?

This is the scenario, upon receiving the item, the key user would encode the expiration date in the warehouse receipt line… then, upon putting the expiration date of the item, it should automatically calculate the Expiration Date - WORKDATE where in the result is the Due Date.

Your code worked… but it does not automatically updating the fields…