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 CRM (Archived)

Calculate end date from start date and duration

(0) ShareShare
ReportReport
Posted on by 710

Hello,

is there way how to calculate end date from start date and duration? Duration is in working days.

Thanks for help

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Karth Profile Picture
    on at

    Hi,

    This isn't possible Out of the Box. You need to achieve this either by client side scripting (OnSave event) or through Plugins. My recommendation is to achieve this though plugins.

    The business logic is fairly simple, but could get complicated when you bring in the business working days and hours into consideration.

    Hope this info helps.

    Thanks,

    Karth

  • Community Member Profile Picture
    on at

    See Karth's answer. Do consider business closure dates when implementing working days in CRM. Business Closure dates can be found in Settings -> Business Management.

  • LiveBomb Profile Picture
    710 on at

    So, i tried

    function count_date ()  {

    if (Xrm.Page.getAttribute("duration").getValue() != null) {

    var enddate = Xrm.Page.data.entity.attributes.get("date_of_end")

    var stardate =  Xrm.Page.data.entity.attributes.get("date_of_stard")

    var duration = Xrm.Page.data.entity.attributes.get("duration");

    enddate.setDate(startdate().getDate + duration().getValue)

    }

    }

    but not working.

  • Verified answer
    Vijay Waghmare Profile Picture
    on at

    You can use something like below to set end date, but as mentioned by Karth and Eyup, you need to consider working days in calculation

    if (Xrm.Page.getAttribute("duration").getValue() != null) {

    var startdate =  Xrm.Page.getAttribute("startdate").getValue();

    var duration = Xrm.Page.getAttribute("duration").getValue();

    var enddate = new Date();

    enddate .setTime(startdate .getTime() +  (duration * 24 * 60 * 60 * 1000));

    Xrm.Page.getAttribute("enddate").setValue(enddate );

    }

    Thanks,

    Vijay Waghmare

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans