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

Calculate difference between two dates?

(0) ShareShare
ReportReport
Posted on by 387

Dear Experts,

I have customized the new page, name is 'Purchase Line Details'. Here I have calculated the the PO approval date. it is working fine. Now, I want to make a difference between indent date and PO approval date....my code is giving the below error. Please help me to short it.

OnAfterGetRecord()

CLEAR(dtApproval);
ApprovalEntry.RESET;
ApprovalEntry.SETRANGE(ApprovalEntry."Document No.","Document No.");
IF ApprovalEntry.FINDLAST THEN BEGIN
AppID:=ApprovalEntry."Approver ID";
dtApproval:=ApprovalEntry."Approval Date-Time";
END;

dtApprove:=DT2DATE(dtApproval); //(conversion date time to date field)


dateDifference:=(dtApprove)-("Requisition Date");

when i try to run my customized page...it is showing the below error...

pastedimage1616567899804v1.png

I have the same question (0)
  • Suggested answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    Please make sure you have the value in dtApproval and also in dtApprove before you calculate the difference.

  • navision begginers Profile Picture
    387 on at

    Yes, your are right. Most of the documents, dtApprove and 'Requisition Date' are blank in purchase line. what should i do sir. Please help me to resolve it.

    Thanks in advance for any help you're able to give with this.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    Put an if condition like below

    if dtApprove <> 0D then begin 

    dtApprove:=DT2DATE(dtApproval); //(conversion date time to date field)


    dateDifference:=(dtApprove)-("Requisition Date");

    end;

  • navision begginers Profile Picture
    387 on at

    i have already tried...but still getting the same error messages. please help me to resolve it.

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,986 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,071 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 975 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans