Note that there are some explanatory texts on larger screens.

plurals
  1. POCalculating difference between dates using query
    primarykey
    data
    text
    <p>I really need help calculating the difference between two dates and it has to be the number of days in a whole number. Here is my HTML and jQuery..</p> <p>This is not working at all... The site should say the date today. Then the user would picka date and click the button "Check our safety record" and at the bottom of the page it says how many days it has been. The jQuery:</p> <pre><code>$(document).ready(function() { $('#safetyRecord').hide(); var monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; var dayNames= ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] var newDate = new Date(); newDate.setDate(newDate.getDate()); $('#today').html(dayNames[newDate.getDay()] + "," +' ' + monthNames[newDate.getMonth()] + ' ' + newDate.getDate() + ","+ ' ' + newDate.getFullYear()); /* $(':button').click(function(){ var start = $('#dateOfLastAccident').val(); var end = $('#today'); var startDate = new Date(start); var endDate = new Date(end); var diff = endDate - StartDate; var numDays = Math.floor( diff / 1000 /60 /60 /24 ); $('#daysSinceLastAccident'+ numDays)(); */ }); </code></pre> <p>The HTML:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;generic safety&lt;/title&gt; &lt;link rel="stylesheet" href="L3hw.css"&gt; &lt;!-- jQuery library hosted by Google Content Distribution Network --&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="L3hw.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;header&gt; &lt;img src="images/genericBanner.png" alt="Generic, Inc."&gt; &lt;p&gt; The New Ventures Mission is to scout profitable growth opportunities in relationships, both internally and externally, in emerging, mission-inclusive markets, and explore new paradigms and then filter and communicate and evangelize the findings. &lt;/p&gt; &lt;/header&gt; &lt;section id="main"&gt; &lt;h1&gt;Safety at generic company&lt;/h1&gt; &lt;h2&gt;Today is &lt;span id="today"&gt;TBD&lt;/span&gt;.&lt;br&gt; Our last lost-work accident was on &lt;input type="date" id="dateOfLastAccident"&gt; &lt;button type="button" id="checkRecord"&gt;Check our safety record&lt;/button&gt; &lt;/h2&gt; &lt;h2 id="safetyRecord"&gt; It has been &lt;span id="daysSinceLastAccident"&gt;TBD&lt;/span&gt; days since our last lost-work accident. &lt;/h2&gt; &lt;/section&gt; &lt;!-- end main --&gt; &lt;footer&gt; &lt;p id="message"&gt; &lt;!-- (an appropriate safety message will appear here) --&gt; &lt;/p&gt; &lt;p&gt;&lt;img src="images/genericBullet.png" alt="*"&gt; Generic Company - we do stuff&lt;/p&gt; &lt;/footer&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload