Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Next Business Date using Javascript

Posted on 2016-10-24
Medium Priority
81 Views
Can someone tell me how this can be achieved and what is the syntax?
0
Question by:teknovation
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 34

Accepted Solution

Big Monty earned 2000 total points
ID: 41857340
found this example online (twekaed to use todays date and the NEXT business day):

``````var startDate = "21-OCT-2016";
startDate = new Date(startDate.replace(/-/g, "/"));
var endDate = "", noOfDaysToAdd = 1, count = 0;
endDate = new Date(startDate.setDate(startDate.getDate() + 1));
if(endDate.getDay() != 0 && endDate.getDay() != 6){
count++;
}
}
``````
0

LVL 59

Expert Comment

ID: 41857563
``````<script>
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];
// TEST FOR FRIDAY
var date = '2016-10-28';
console.log("NBD for : " + date + " is [" + nbd + "] => " + days[nbd]);

//TEST FOR MONDAY
date = '2016-10-24';
console.log("NBD for : " + date + " is [" + nbd + "] => " + days[nbd]);

{
var day = new Date (dt).getDay() + 1;
day = (day > 5) ? 1 : day;
return day;
}
</script>
``````
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
###### Suggested Courses
Course of the Month10 days, 16 hours left to enroll