how to get date difference from calendar date to system date using jquery?

Posted by Hariinakoti under jQuery on 9/28/2012 | Points: 10 | Views : 12373 | Status : [Member] | Replies : 5
Hi All,
I want to date difference from calendar date to system date after that i want to display result in another textbox using jquery.Please any body suggest me asap.
ex:(15-05-1990)-(28-09-2012)=12
i want result like that

Thanks & Regards
Hari



Responses

Posted by: Pgayath on: 9/28/2012 [Member] Starter | Points: 25

Up
0
Down
hi Hari

$('#test').datepicker({    

onSelect: function() {
var date = $(this).datepicker('getDate');
var today = new Date();
var dayDiff = Math.ceil((today - date) / (1000 * 60 * 60 * 24)); } });


Please refer http://stackoverflow.com/questions/5142693/jquery-ui-datepicker-difference-in-days

Thanks and Regards,
Gayathri P

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Solijoseph on: 9/28/2012 [Member] Starter | Points: 25

Up
0
Down


Refer this link'
http://www.codeproject.com/Articles/18317/How-to-calculate-difference-between-two-dates-usin

Thanks & Regards
Solimon Joseph

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/28/2012 [Member] Starter | Points: 25

Up
0
Down
@pgayath,
already i applied that code but it is not working

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 9/28/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
Hariinakoti
try this

<script type="text/javascript">
$(function () {
$('.date-picker').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'MM yy',
onClose: function (dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
});
});

function DateCalc() {
var t1 = document.getElementById("startDate").value;
var Nt=new Date();
var t2 = t1.split(" ");
var yr = t2[1];
var CuYr= Nt.getFullYear();
if (yr > CuYr) {alert('yes');
}
else { alert('No'); }
}

</script>

<style>
.ui-datepicker-calendar {
display: none;
}
</style>

<title></title>
</head>
<body>
<form id="form1" runat="server">
<label for="startDate">Date :</label>
<input name="startDate" id="startDate" class="date-picker" />
<asp:Button ID="bt1" runat="server" Text ="click" OnClientClick="DateCalc();" />

</form>


Mark as Answer if its helpful to you

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 9/28/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

Please mark as answer if it helpful to you.


Mark as Answer if its helpful to you

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response