How to compare two dates in servoy that is I would like check whether date stored in database is current date(not time).
Do I need to add a new routine to compare date, month and year seperately with current date.
How to compare two dates in servoy that is I would like check whether date stored in database is current date(not time).
Do I need to add a new routine to compare date, month and year seperately with current date.
Hi,
You could use the following function. Pass in the dates you want to compare, tell the function to ignore the time and if the result is 0 then the dates are the same.
function DAYSBETWEEN(dDate1, dDate2, lIncludeTime){
var nDays=0;
if(!lIncludeTime){
dDate1=new Date(dDate1.getFullYear(),dDate1.getMonth(),dDate1.getDate());
dDate2=new Date(dDate2.getFullYear(),dDate2.getMonth(),dDate2.getDate());
nDays=Math.round((dDate1.valueOf()-dDate2.valueOf())/(60*60*24*1000));
}else{
nDays=(dDate1.valueOf()-dDate2.valueOf())/(60*60*24*1000);
}
return nDays;
}
This function was provided by Juan Antonio Santana Medina.
Awesome, GREAT! Thanks Omar