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 :
Microsoft Dynamics NAV (Archived)

i want to calculate the duration between two dates?

(0) ShareShare
ReportReport
Posted on by 1,751

i have a two data field ,FromDate,ToDate of data type Date.i want to calculate the duration between these two dates and want to assign the result to the Tenure field of datatype DateFormula.?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Jatin Patel Profile Picture
    2,641 on at

    Hi Javed,

    You need to declare one integer variable e.g. duration and then

    duration = ToDate - FromDate;

    it will gives you duration between two dates and you can use that value in dateformula field .

  • mmv Profile Picture
    11,471 on at

    Hi,

    FromDate - ToDate will give you the number of days between these two dates.  In order to use that in the DateForumula, you may use the below example:

    NewDate := CALCDATE(FORMAT(FromDate - ToDate) + 'D',TODAY)

    In the above example, program will add the difference of two dates to TODAY.

  • Verified answer
    4BzSoftware Profile Picture
    6,073 on at

    Hi Javedakhtar,

    EVALUATE(Tenure, '<' + FORMAT(ToDate - FromDate) + 'D>');

  • javedakhtar Profile Picture
    1,751 on at

    Hi

    i tried but it didnt worked out

  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at

    Can you please let us know what did you try? and what didn't work? and how are you expecting it to work? with example

  • javedakhtar Profile Picture
    1,751 on at

    HI

    its working ,but there is minus sign with duration values;

    fromDate=010515 todate :=150515

    tenure:=-14D

  • Verified answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at

    use Todate first as it is bigger EVALUATE(Tenure, '<' + FORMAT(ToDate - FromDate) + 'D>');

  • javedakhtar Profile Picture
    1,751 on at

    Thanks everyone its working

  • Verified answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    Javed,

    You can also use ABS function to return it as positive

    EVALULATE(Tenure,'<' + FORMAT(ABS(ToDate-FromDate)) + 'D>')

  • javedakhtar Profile Picture
    1,751 on at

    Thanks Suresh Sir

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans