web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Date is not valid

(0) ShareShare
ReportReport
Posted on by 5

OnAfterGetRecord()
IF "Solved Date" = 0D THEN
Aging := WORKDATE - "Reqeusted Date"
ELSE
Aging := "Solved Date" - "Reqeusted Date";

Aging is integer data type.

I have the same question (0)
  • Suggested answer
    Andy Sather Profile Picture
    on at

    Would you be able to describe the issue you are running into?

  • Suggested answer
    Lars Lohndorf-Larsen Profile Picture
    on at

    Hi Narayan,

    You are right that Date - AnotherDate should return an Integer. But only if the date is defined. If one of the dates is undefined, then you get the error. So you need to test more for 0D, for example

    IF "Requested Date" <> 0D THEN

      Aging := WORKDATE - "Requested Date"

    ELSE

      Aging := 0 // (or any ohter default value)

    So in this code you test correctly on "Solved date", but you also need to test that "Requested Date" <> 0D before you can use it in a calculateion,

    hope that helps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,468

#2
YUN ZHU Profile Picture

YUN ZHU 923 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans