Is there any way in Classic ASP VBScript to get the number of weekdays between 2 dates? Obviously, we have the DateDiff()
function but this will pull back the total number of days but I would like to omit the weekends.
相关问题
- If condition not working in classic ASP
- How to programmatically convert Access 1997 .mdb t
- IE8 Form Not Submitting (Intermittent)
- Server.Transfer from ASP to ASP.Net
- VBScript / ADODB Syntax Issue with adArray?
相关文章
- Can a VBScript function return a dictionary?
- UTC Time Assignment in VBScript
- Copy and Rename File VBScript
- How do I open a file with VBScript?
- ZURB Foundation, switching tab programmatically
- Import WinAPI Function in *.VBS File
- How to reference the mail which triggered the outl
- Accessing COM Component from Classic ASP which con
VBScript does not include the requested operation, but as
DateDiff
with aww
interval returns the number of Sundays between two dates, ensuring that start and end dates are out of the weekend we can directly calculate the number of working days:You're right,
DateDiff()
doesn't cover this but it can be used in conjunction withWeekDay()
to work out if aDay
falls on a weekend.By using
DateDiff()
to get the number of days we can then use aFor
loop to step through the days usingDateAdd()
to increment the day as we go and check whether the incremented date value is a particularWeekDay()
. We can then decide based on this outcome whether to increment a counter that is storing our resulting number of weekdays.Below is an example of how you would do this, the main logic has been encapsulated in a Function that you could include in a
#include
script file to use in multiple pages.Output:
This is just a quick example and doesn't cover every possible usage case, the idea is it gives you a starting point that you can work from and improve.