Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 372729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:14:20+00:00 2026-05-12T14:14:20+00:00

I have tried like this <script type=text/javascript> var date2=02/09/2009; var date1=03/12/2009; var diff =

  • 0

I have tried like this

<script type="text/javascript">
     var date2=02/09/2009;
     var date1=03/12/2009;
     var diff = date1.getDate()-date2.getDate();
     alert (diff);

</script>

but it’s not working, is that reason getDate will work only for Date?

How to find the difference between these two dates? Am I not able use this function, because I am adding javascript in salesforce CRM apex pages?

Edit 1 : infact this too not working

<script type="text/javascript">
     var date2= new Date ("02/09/2009");
     var date1= new Date ("04/09/2009");
     var diff = date1.getDate()-date2.getDate();
     alert (diff);

</script>

Edit 2 : its not working too …

<script type="text/javascript">
     var date2= "02/09/2009";
     var date1= "04/09/2009";
     var diff2 =    new Date(Date.parse("03/12/2009")-
                        Date.parse("02/09/2009")).toLocaleDateString();

// var new_date = new Date (1970, 01, 01);
// var diff3 = diff2.getDate();
alert (diff2);

</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:14:20+00:00Added an answer on May 12, 2026 at 2:14 pm
    
    <script language="JavaScript">
    <!--
    function dstrToUTC(ds) {
     var dsarr = ds.split("/");
     var mm = parseInt(dsarr[0],10);
     var dd = parseInt(dsarr[1],10);
     var yy = parseInt(dsarr[2],10);
     return Date.UTC(yy,mm-1,dd,0,0,0);
    }
    
    function datediff(ds1,ds2) {
     var d1 = dstrToUTC(ds1);
     var d2 = dstrToUTC(ds2);
     var oneday = 86400000;
     return (d2-d1) / oneday;
    }
    
    // test cases are below
    
    var a; var b;
    
    a = "01/09/1999";
    b = "01/10/1999";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "01/12/1999";
    b = "01/19/1999";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "01/19/1999";
    b = "01/12/1999";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "01/03/1999";
    b = "01/13/1999";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "04/30/1999";
    b = "05/01/1999";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "05/30/1999";
    b = "06/01/1999";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "02/28/1999";
    b = "03/01/1999";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "02/28/2000";
    b = "03/01/2000";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "01/01/1999";
    b = "12/31/1999";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "01/01/2000";
    b = "12/31/2000";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    a = "12/15/1999";
    b = "01/15/2001";
    document.write("From "+a+" to "+b+" is "+datediff(a,b)+" day(s)<br>");
    
    // -->
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 385k
  • Answers 385k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Neither knowing C nor knowing the lower-level details of implementation… May 14, 2026 at 11:25 pm
  • Editorial Team
    Editorial Team added an answer Definitely use Linq2Twitter - http://linqtotwitter.codeplex.com/ It's UpdateStatus method has 11… May 14, 2026 at 11:25 pm
  • Editorial Team
    Editorial Team added an answer I'm on the VS Profiler team, so feel free to… May 14, 2026 at 11:25 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.