Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
TeamSite
TeamSite, LiveSite and OpenDeploy
FormAPI to determine number of days between dates
System
Someone sent me a private message asking how to compare two dates in a template (for instance to ensure one occurs before the other). I had done something like this (not sure it's totally accurate):
function daysDiff( d1, d2 )
{
diffMilli = d2.getTime() - d1.getTime();
return( Math.round( diffMilli / 86400000 ));
}
This should ensure /SomeField is not more than 365 days into the future, but you could also check against another field on the form (say on an onSave event):
var someDate = new Date( IWDatacapture.getItem( "/SomeField" ).getValue());
if ( daysDiff( new Date(), someDate ) > 365 )
{
alert( "SomeField must be fewer than 365 days into the future." );
return( false );
}
Find more posts tagged with
Comments
There are no comments yet