// this function used to update the dateformat into yyyy-mm-dd to yyyy-dd-mm
function changeDateFormat(date){
var inputDate, dd, mm, yyyy, convertedDateString, convertedDate;
inputDate = date.toString();
// get date, month, fullyear from date
dd = inputDate.slice(5,7);
mm = inputDate.slice(-2);
yyyy = inputDate.slice(0,4);
convertedDateString = yyyy + '-' + mm + '-' + dd;
convertedDate = new Date(convertedDateString);
return convertedDate;
}
// this function used to do the search function
function searchDate() {
var input_startDate, input_stopDate, tr, i;
// get the values and convert to date
input_startDate = new Date(document.getElementById("From_Date").value);
input_stopDate = new Date(document.getElementById("To_Date").value);
tr = document.querySelectorAll("#table_id tbody tr");
for (var i = 0; i < tr.length; i++) {
// ensure we have a relevant td
var td = tr[i].getElementsByTagName("td");
if (!td || !td[2]) continue;
// you need to get the text and convert to date
var tdDateString = td[2].textContent;
var tdDate = changeDateFormat(tdDateString);
// now you can compare dates correctly
if (tdDate) {
if (tdDate >= input_startDate && tdDate <= input_stopDate) {
// show the row by setting the display property
tr[i].style.display = 'table-row;';
} else {
// hide the row by setting the display property
tr[i].style.display = 'none';
}
}
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.