I have implemented a datepicker for the startdate and end date in my project with the following code snippet:
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script type="text/javascript">
$(function () {
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
$( "#endDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
});
</script>
<style type="text/css">
.search_textbx
{
background-image:url('/SalesPropeller/calendar.jpg');
background-repeat:no-repeat;
background-position:right;
}
</style>
<form name="form" action="quotationSearchResult.jsp" method="post">
<input type="text" id="startDate" name="startDate" class="search_textbx" readonly="readonly" placeholder="    dd-mm-yyyy"/>
<input type="text" id="endDate" name="endDate" class="search_textbx" readonly="readonly" placeholder="    dd-mm-yyyy"/></td>
</form>
In the quotationSearchResult.jsp file, I am fetching search results based on certain criteria.
<div id="divRight">
<%
int count = 0;
int SlNo=1;
%>
<hr />
<h3>Search Result for <u><%= request.getParameter("companyName")%></u> is : </h3>
<hr/>
<div id="divtable_wrapper">
<div id="divtbody" style="height: 470px;">
<form method="post" name="form">
<table class="divtable" width="1140">
<div id="divheader">
<thead>
<tr>
<!-- Table headings -->
</tr>
</thead>
</div>
<%
// Java SQL query and result processing logic
%>
<%
while (rs.next()) {
%>
<tr>
<!-- Display data from database -->
</tr>
<%
}
%>
<%
} catch (Exception e) {
e.printStackTrace();
}
%>
</table>
</form>
<br>
<span style="float: left;"> <b><%= count%></b> Search Result Found.</span>
<br><br>
</div>
</div>
</div>
Upon testing with different start and end dates, I noticed discrepancies in the comparison results which you can see in these images: https://i.sstatic.net/2WduJ.png https://i.sstatic.net/9bFQ6.png However, when using different dates like "07-12-2015" and "18-01-2016", the records are not being fetched as expected: https://i.sstatic.net/cKQDc.png https://i.sstatic.net/A5mmL.png
This issue seems to be related to comparing years properly in the SQL database backend. https://i.sstatic.net/GAHIa.png