Activer Server Pages create a loop to generate dates, hour and minutes

Hi Experts

I want to generate dates from to day to next year the same day, ie:
13/11/2017 18:57:29
14/11/2017 18:57:29
15/11/2017 18:57:29
16/11/2017 18:57:29
etc...

But I want to exclude Fridays and Saturdays

And I want to divide each day by 11 hours starting from 8 AM to 7PM,  and each hour divided by 15 minutes

Ie:
13/11/2017 08:00:00
13/11/2017 08:15:00
13/11/2017 08:30:00
13/11/2017 08:45:00
13/11/2017 09:00:00
13/11/2017 09:15:00
13/11/2017 09:30:00
etc... until
13/11/2017 : 19:00:00

And then display next day, and so on

Can anyone please help me with the code.
michael el halabistudentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
startDate = "11/9/2019 8:00:00 AM"
endDate = dateAdd("y",1,startDate)
currentDate = startDate

Do Until currentDate = endDAte

  response.write currentDate &"<br>"
  currentDate=dateAdd("n",15,currentDate

Loop

Open in new window


See dateAdd https://www.w3schools.com/asp/func_dateadd.asp
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
This is the one that should do the trick including excluding Fri and Sat

<%
startDate = "11/9/2017 8:00:00 AM"
endDate = dateAdd("yyyy",1,startDate)
currentDate = startDate

   
Do until cdate(currentDate) > cdate(endDate)

  if Weekday(currentDate) <> 6 and Weekday(currentDate) <> 7 then
  response.write FormatDateTime(currentDate,1)&" "&FormatDateTime(currentDate,3)   &" | Weekday Number: " & Weekday(currentDate) & " | Weekday Name:"& weekdayname(Weekday(currentDate)) &"<br>"
  response.flush	
  end if
  currentDate=dateAdd("n",15,currentDate)
  
   
Loop
   
%>

Open in new window

Output
Thursday, November 9, 2017 8:00:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 8:15:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 8:30:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 8:45:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 9:00:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 9:15:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 9:30:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 9:45:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 10:00:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 10:15:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 10:30:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 10:45:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 11:00:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 11:15:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 11:30:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 11:45:00 AM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 12:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 12:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 12:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 12:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 1:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 1:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 1:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 1:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 2:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 2:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 2:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 2:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 3:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 3:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 3:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 3:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 4:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 4:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 4:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 4:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 5:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 5:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 5:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 5:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 6:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 6:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 6:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 6:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 7:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 7:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 7:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 7:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 8:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 8:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 8:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 8:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 9:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 9:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 9:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 9:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 10:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 10:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 10:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 10:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 11:00:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 11:15:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 11:30:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Thursday, November 9, 2017 11:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Sunday, November 12, 2017 12:00:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 12:15:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 12:30:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 12:45:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 1:00:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 1:15:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 1:30:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 1:45:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 2:00:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 2:15:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 2:30:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 2:45:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 3:00:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 3:15:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 3:30:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 3:45:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 4:00:00 AM | Weekday Number: 1 | Weekday Name:Sunday
Sunday, November 12, 2017 4:15:00 AM | Weekday Number: 1 | Weekday Name:Sunday

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
michael el halabistudentAuthor Commented:
awesome
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

michael el halabistudentAuthor Commented:
awesome solution, thx expert
michael el halabistudentAuthor Commented:
just a little problem

Each day time must start at 8:00 AM and  stops at 07:PM

Your code does start at 8:00 am but never ends

ie :
Thursday, November 09, 2017 11:45:00 PM | Weekday Number: 5 | Weekday Name:Thursday
Sunday, November 12, 2017 12:00:00 AM | Weekday Number: 1 | Weekday Name:Sunday

Thursday must start at 8:00 AM and ends at 07:00 PM
Sunday  must start at 8:00 AM and ends at 07:00 PM

Do you please have a fix ?
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
startDate = "11/9/2017 8:00:00 AM"
endDate = dateAdd("yyyy",1,startDate)
currentDate = startDate

   
Do until cdate(currentDate) > cdate(endDate)

  if Weekday(currentDate) <> 6 and Weekday(currentDate) <> 7 then
	if hour(currentDate)>=8 AND (hour(currentDate)< 19 OR formatDateTime(currentDate,4) = "19:00")  then
        response.write FormatDateTime(currentDate,1)&" "&FormatDateTime(currentDate,3)   &" | Weekday Number: " & Weekday(currentDate) & " | Weekday Name:"& weekdayname(Weekday(currentDate)) &"<br>"
  response.flush
	end if						  
  end if
  currentDate=dateAdd("n",15,currentDate)
  
   
Loop

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.