michael el halabi
asked on
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
awesome
ASKER
awesome solution, thx expert
ASKER
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 ?
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 ?
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
See dateAdd https://www.w3schools.com/asp/func_dateadd.asp