Wrox Programmer Forums
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 23rd, 2004, 10:31 AM
Registered User
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting date for next day of week

I have a table of delivery dates for customer companies, set up with checkbox fields for Mon - Fri. Also a table of holidays with specific dates (7/4/2004, etc.). I need to calculate the next delivery date; for instance if today is Friday and delivery dates are Mon, Wed, and Fri then the next delivery day would be Mon. Can't figure out how to get the date of the next delivery day. Not all companies would have the same delivery days and not all companies would have the same number of deliveries per week. Also, if the next delivery date falls on a holiday, as entered in the holidays table, then that delivery day would move to the next delivery day. I can't seem to get a handle on this. Does anybody have any ideas?
Old March 23rd, 2004, 01:24 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts

The WeekDay function will return the day of the week for the passed in date. Therefore if each of your check boxes are assigned a number (e.g. Monday = 1, Tuesday = 2, etc.) then you can use the WeekDay function to test if the date is one of the selected days. If it is not then you can use the DateAdd function to increment the date until it is an acceptable date.

The syntax of the WeekDay functions is:

WeekDay(date, [firstdayofweek])

The date part should be an expression that can represent a date (date, string or numeric varable).
The firstdayofweek part is optional and if included specifies the first day of the week, if it is omitted then vbSunday is assumed. Any of the following constants can be used as the firstdayofweek part:


The DateAdd function returns a date and it's syntax is:

DateAdd(interval, number, date)

Where the interval part is one of the following:

yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second

The number part is the number of intervals you want to add and the date part is the date you want to add to.

I hope this helps.

Owain Williams

Similar Threads
Thread Thread Starter Forum Replies Last Post
getting the same day of the week. crabjoe Classic ASP Basics 3 February 27th, 2008 12:45 PM
DAY of the week wdepreter Excel VBA 3 February 7th, 2007 06:44 AM
Day of week finder mrjaygreene Classic ASP Basics 6 May 13th, 2006 04:43 PM
Conversion to 7 day week. kinouye BOOK: Beginning VB.NET Databases 0 December 3rd, 2005 03:58 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.