Hi

I have a booking form where people enter a FromDate and a ToDate and select
a recurring day like Tuesday.

So that data is for instance 7-jul-2003 to 28-jul-2003 and recurring on
Tuesday.
What I want to be able to do is calculate the dates for the Tuesday's within
the FromDate ToDate range and submit them to a database.
And even better still be able to calculate 2 days like Tuesday and Friday
with in the range.

Is this possible ????

Regards

Dave

Re: Date Range by Bob

Bob
Mon Jul 07 07:51:38 CDT 2003

dave wrote:
> Hi
>
> I have a booking form where people enter a FromDate and a ToDate and
> select a recurring day like Tuesday.
>
> So that data is for instance 7-jul-2003 to 28-jul-2003 and recurring
> on Tuesday.
> What I want to be able to do is calculate the dates for the Tuesday's
> within the FromDate ToDate range and submit them to a database.
> And even better still be able to calculate 2 days like Tuesday and
> Friday with in the range.
>
> Is this possible ????
>
Yes



Re: Date Range by Dr

Dr
Mon Jul 07 17:38:47 CDT 2003

JRS: In article <3f097353$1@news.umist.ac.uk>, seen in news:microsoft.p
ublic.scripting.vbscript, dave <david.callagan@umist.ac.uk> posted at
Mon, 7 Jul 2003 13:41:42 :-

>I have a booking form where people enter a FromDate and a ToDate and select
>a recurring day like Tuesday.
>
>So that data is for instance 7-jul-2003 to 28-jul-2003 and recurring on
>Tuesday.
>What I want to be able to do is calculate the dates for the Tuesday's within
>the FromDate ToDate range and submit them to a database.
>And even better still be able to calculate 2 days like Tuesday and Friday
>with in the range.

If the range is reasonably short, you might as well just increment the
date and test for Tuesday each time, until you reach the end date (exact
meaning of within?); you can test for Friday at the same time.

To be more subtle, for longer periods, go ahead from the start to the
first Tuesday - the increment can be calculated as something like (3
(Tues) - CurrentDoW + 7) mod 7; go back from the end to the last
Tuesday - the decrement can be calculated as something like (CurrentDoW
- 3 (Tues) + 7) mod 7; subtract the daycounts of the Tuesdays, divide by
7, and add 1.

My <URL:http://www.merlyn.demon.co.uk/ws-dates.htm> may help a bit.

Alternatively, date-to-integer plus K, where K is in 0..6, \ 7 is the
Number of Thursdays Since Datum. Work this out for both dates, and
subtract. at least one of the integers will need +/-1, to allow for
inclusive/exclusive range.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.