Need help with calc. a future date. Right now I have it where it calc. 25 days in the future. But need 25 working days in the future.
form1.Page1.Button1::click - (JavaScript, client)
var oNow = new Date();
// add 25 days and make new date object
oNow = new Date(oNow.getFullYear(), oNow.getMonth(), (oNow.getDate() + 25) )
// dispaly new date information
sMsg = "In 25 days it will be " + util.printd("mm/dd/yyyy", oNow);
sMsg += "\n" + "The day of the week will be " + util.printd("dddd", oNow);
app.alert(sMsg, 3, 0)
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I haven't tried this but it should be close:
var oNow = new Date();
var oDay = util.printd("dddd", oNow);
// add 25 working days and make new date object
if (oNow == "Saturday")
{
oNow = new Date(oNow.getFullYear(), oNow.getMonth(), (oNow.getDate() + 35 + 2));
}
else if (oNow == "Sunday")
{
oNow = new Date(oNow.getFullYear(), oNow.getMonth(), (oNow.getDate() + 35 + 1));
}
else
{
oNow = new Date(oNow.getFullYear(), oNow.getMonth(), (oNow.getDate() + 35));
}
// dispaly new date information
sMsg = "In 25 working days it will be " + util.printd("mm/dd/yyyy", oNow);
sMsg += "\n" + "The day of the week will be " + util.printd("dddd", oNow);
app.alert(sMsg, 3, 0);
The 35 is seven days for for each of the 5-day working weeks. The +2 and +1 push a weekend into the next working day.
Hope that works,
Niall
Views
Replies
Total Likes
Hi,
I haven't tried this but it should be close:
var oNow = new Date();
var oDay = util.printd("dddd", oNow);
// add 25 working days and make new date object
if (oNow == "Saturday")
{
oNow = new Date(oNow.getFullYear(), oNow.getMonth(), (oNow.getDate() + 35 + 2));
}
else if (oNow == "Sunday")
{
oNow = new Date(oNow.getFullYear(), oNow.getMonth(), (oNow.getDate() + 35 + 1));
}
else
{
oNow = new Date(oNow.getFullYear(), oNow.getMonth(), (oNow.getDate() + 35));
}
// dispaly new date information
sMsg = "In 25 working days it will be " + util.printd("mm/dd/yyyy", oNow);
sMsg += "\n" + "The day of the week will be " + util.printd("dddd", oNow);
app.alert(sMsg, 3, 0);
The 35 is seven days for for each of the 5-day working weeks. The +2 and +1 push a weekend into the next working day.
Hope that works,
Niall
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies