Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Compare two date fields, select the newest of the two and populate a third.

Posted on by Microsoft Employee

Hi, does anyone know how I can compare two date fields, select the newest of the two and populate a third date field in CRM using JavaScript?

*This post is locked for comments

  • Suggested answer
    Kishor Kumar Profile Picture
    Kishor Kumar 3,702 on at
    RE: Compare two date fields, select the newest of the two and populate a third.

    Hi Graeme, check this,

    dynamicscrmguru.com/.../how-to-compare-dates-using-javascript

  • Suggested answer
    Ryan Maclean Profile Picture
    Ryan Maclean 3,070 on at
    RE: Compare two date fields, select the newest of the two and populate a third.

    For clarity, are you trying to update the third date field with the later of the two dates?  If so, you could achieve this using business rules:

    IF

    Date A > Date B

    THEN

    Set Date C = Date A

    OTHERWISE

    IF

    Date B > Date A

    THEN

    Set Date C = Date B

    See below:

    22220.Capture.PNG

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Compare two date fields, select the newest of the two and populate a third.

    Hi Graeme ,

    you can definitely compare two dates using > or < operators.

    have  a look : stackoverflow.com/.../compare-two-dates-with-javascript

    you can compare if (a>b)

    a will the newest one.

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans