Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

i want to calculate the duration between two dates?

Posted on by 1,745

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
    javedakhtar 1,745 on at
    RE: i want to calculate the duration between two dates?

    Thanks Suresh Sir

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 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
    javedakhtar 1,745 on at
    RE: i want to calculate the duration between two dates?

    Thanks everyone its working

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 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
    javedakhtar 1,745 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
    Mohana Yadav 59,139 Super User 2024 Season 2 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
    javedakhtar 1,745 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
    4BzSoftware 6,071 on at
    RE: i want to calculate the duration between two dates?

    Hi Javedakhtar,

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

  • mmv Profile Picture
    mmv 11,465 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
    Jatin Patel 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

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans