ColdFusion Script to compare a date value
<cfscript>
function isBetween(compVal, FirstVal, SecondVal)
{
var myRetVal = false;
if(FirstVal LTE SecondVal)
{
if(compVal GTE FirstVal AND compVal LTE SecondVal)
RetVal = true;
}
else
{
if(compVal GTE SecondVal AND compVal LTE FirstVal)
RetVal = true;
}
return RetVal;
}
</cfscript>
<cfif #isBetween(#DateFormat(10/25/2012,"mm/dd/yyyy")#, #dateFormat(10/20/2012,'mm/dd/yyyy')#,#dateFormat(10/30/2012,'mm/dd/yyyy')# )#>
<cfoutput>The date is between the given values </cfoutput>
<cfelse>
<cfoutput>The date is not between the given values </cfoutput>
</cfif>
function isBetween(compVal, FirstVal, SecondVal)
{
var myRetVal = false;
if(FirstVal LTE SecondVal)
{
if(compVal GTE FirstVal AND compVal LTE SecondVal)
RetVal = true;
}
else
{
if(compVal GTE SecondVal AND compVal LTE FirstVal)
RetVal = true;
}
return RetVal;
}
</cfscript>
<cfif #isBetween(#DateFormat(10/25/2012,"mm/dd/yyyy")#, #dateFormat(10/20/2012,'mm/dd/yyyy')#,#dateFormat(10/30/2012,'mm/dd/yyyy')# )#>
<cfoutput>The date is between the given values </cfoutput>
<cfelse>
<cfoutput>The date is not between the given values </cfoutput>
</cfif>
Comments
Post a Comment