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 :

CRM 2016 - How to Compare Two Dates Using JavaScript

Arpit Shrivastava Profile Picture Arpit Shrivastava 7,518 User Group Leader

I have encountered many confused developers attempting to compare two dates using JavaScript. There are many methods or algorithms for comparing dates but I am showing the simplest ways to compare dates as well as times using JavaScript.


This article will help you to resolve problems to compare two Dates using JavaScript :



<script type="text/javascript"language="javascript">
   function CompareDates() 
   {      
       var dateOne = new Date("2017/04/12"); //Year, Month, Date
       var dateTwo = new Date("2017/05/12"); //Year, Month, Date
       if (dateOne > dateTwo) 
        {
            alert("Date One is greater then Date Two.");
        }
        else
        {
            alert("Date Two is greater then Date One.");
        }
    } 
    CompareDate();
</script>
Can also refer my below article for more details:
Cheers

This was originally posted here.

Comments

*This post is locked for comments