As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
I have 2 calendar controls in YYMD format and I am trying to find difference in days so that I could alert if date range is more than 60 days.
I am using this logic.
var dt_1 = document.form1.DT1.value;
var dt_2 = document.form1.DT2.value;
var no_of_days = dt_2 - dt_1;
if (dt_1 == '' && dt_2 == '')
{
alert("Please enter a range for Date");
}
if (dt_1 > dt_2)
{
alert("FROM date cannot be greater than TO date");
}
alert(no_of_days);
Everything works but I dont get the number of days. It shows 'NaN' in the alert box when I try to get value in no_of_days. Can someone help me on this?
Thank youThis message has been edited. Last edited by: Kerry,
You really should try Google, 'javascript difference between two dates' -should provide links to the answer. Most likely the DT1 control is a text box, hence it's alphanumeric and alphanumeric - alphanumeric will most likely lead to NaN - the NaN property represents "Not-a-Number" value.
You need to convert the value of these text boxes to JavaScript date variables and then subtract, but Google will lead you to this.
Bonne chance.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
Originally posted by Francis Mariani: You really should try Google, 'javascript difference between two dates' -should provide links to the answer. Most likely the DT1 control is a text box, hence it's alphanumeric and alphanumeric - alphanumeric will most likely lead to NaN - the NaN property represents "Not-a-Number" value.
You need to convert the value of these text boxes to JavaScript date variables and then subtract, but Google will lead you to this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function Calc1()
{
var dt_1 = new Date(document.getElementById('DT1').value);
var dt_2 = new Date(document.getElementById('DT2').value);
//Set 1 day in milliseconds
var one_day = 1000 * 60 * 60 * 24;
//Calculate difference between the two dates, and convert to days
var no_of_days = (dt_2 - dt_1) / (one_day);
if (dt_1 == '' && dt_2 == '')
{
alert("Please enter a range for Date");
}
if (dt_1 > dt_2)
{
alert("FROM date cannot be greater than TO date");
}
alert(no_of_days);
}
</script>
</head>
<body>
<input id="DT1" type=text value="2010/10/23">
<input id="DT2" type=text value="2010/10/24">
<input type="button" onClick="Calc1();" value="Calculate">
</body>
</html>
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
And I should have stated that the difference between two dates is returned in milliseconds. To find out how many days, divide by the number of milliseconds in one day.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server