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

  • javedakhtar Profile Picture
    1,751 on at
    RE: i want to calculate the duration between two dates?

    Thanks Suresh Sir

  • Verified answer
    Suresh Kulla Profile Picture
    47,787 on at
    RE: i want to calculate the duration between two dates?

    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
    RE: i want to calculate the duration between two dates?

    Thanks everyone its working

  • Verified answer
    Mohana Yadav Profile Picture
    60,228 Super User 2025 Season 1 on at
    RE: i want to calculate the duration between two dates?

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

  • javedakhtar Profile Picture
    1,751 on at
    RE: i want to calculate the duration between two dates?

    HI

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

    fromDate=010515 todate :=150515

    tenure:=-14D

  • Suggested answer
    Mohana Yadav Profile Picture
    60,228 Super User 2025 Season 1 on at
    RE: i want to calculate the duration between two dates?

    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
    RE: i want to calculate the duration between two dates?

    Hi

    i tried but it didnt worked out

  • Verified answer
    4BzSoftware Profile Picture
    6,073 on at
    RE: i want to calculate the duration between two dates?

    Hi Javedakhtar,

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

  • mmv Profile Picture
    11,467 on at
    RE: i want to calculate the duration between two dates?

    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.

  • Suggested answer
    Jatin Patel Profile Picture
    2,641 on at
    RE: i want to calculate the duration between two dates?

    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 .

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans