Skip to main content

Notifications

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.

  • Suggested answer
    RE: Date is not valid

    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

  • Suggested answer
    Andy Sather Profile Picture
    Andy Sather on at
    RE: Date is not valid

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

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans