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

Announcements

No record found.

News and Announcements icon
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
    Microsoft Employee on at

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

  • Suggested answer
    Lars Lohndorf-Larsen Profile Picture
    Microsoft Employee 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,965 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,125 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 961 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans