Work week

M

Mike D

I need to provide a pulldown with work weeks displayed. Is there any easy
way to do this?

I would like to go 6 months from the current date and show a week as Oct. 11
- 15. Which is Monday to Friday.

Any help appreciated.

Mike
 
T

TomB

There's probably a better solution, but this should work.

<%
Response.write "<select name=""week"">" & vbCrLf
Dim currentMonday
Dim incrementingMonday
Dim endingFriday

currentMonday=DateAdd("d",Date, Weekday(Date)-6)

endingFriday=DateAdd("m",6,DateAdd("d",currentMonday,4))
incrementingMonday=currentMonday

do while incrementingMonday<endingFriday
Response.Write vbTab & _
"<option value=""" & incrementingMonday & """>" & _
incrementingMonday & " - " & _
DateAdd("d",4, incrementingMonday) & _
"</option>" & vbCrLf
incrementingMonday=DateAdd("d",7,incrementingMonday)
Loop
Response.write "</select>"
%>
 
M

Mike D

TomB said:
There's probably a better solution, but this should work.

<%
Response.write "<select name=""week"">" & vbCrLf
Dim currentMonday
Dim incrementingMonday
Dim endingFriday

currentMonday=DateAdd("d",Date, Weekday(Date)-6)

endingFriday=DateAdd("m",6,DateAdd("d",currentMonday,4))
incrementingMonday=currentMonday

do while incrementingMonday<endingFriday
Response.Write vbTab & _
"<option value=""" & incrementingMonday & """>" & _
incrementingMonday & " - " & _
DateAdd("d",4, incrementingMonday) & _
"</option>" & vbCrLf
incrementingMonday=DateAdd("d",7,incrementingMonday)
Loop
Response.write "</select>"
%>
This is what I did. I was hoping for a simpler solution but it wasn't too
bad after all.

Function DisplayDatePulldown()
Dim datToday, datEndTimePeriod
Dim intDaysSinceMonday, datLastMonday
Dim x, datLoopDate, strOut

datToday = Date()

intDaysSinceMonday = -Weekday(datToday) + 2
datLastMonday = DateAdd("D", intDaysSinceMonday, datToday)
datEndTimePeriod = DateAdd("M", 6, datLastMonday)

strOut = "<select size=""1"" name=""WeekOf"">"
strOut = strOut & "<option>Select Week</option>" & "<br>"

For x = 0 to DateDiff("w", datLastMonday, datEndTimePeriod, 2)
datLoopDate = DateAdd("WW", x, datLastMonday)

strOut = strOut & "<option Value=" & Chr(34) & datLoopDate & Chr(34) & ">" & _
UCase(MonthName(Month(datLoopDate), True)) & ". " & _
Day(datLoopDate) & " - " & Day(datLoopDate) + 4 & "</option>" & "<br>"

Next

DisplayDatePulldown = strOut & "</select>" & "<br>"
End Function

Thanks for you reply
Mike
 
A

Aaron [SQL Server MVP]

I just haven't
made up my mind how much I will need it.

What is the concern? Size? The table is tiny, even if you have dozens of
years in it...
 
M

Mike D

What is the concern? Size? The table is tiny, even if you have dozens of
years in it...
It's not the size. I'm just not sure of what to store in the table. If I
store everyday the only ones I am concerned with is the Monday's and
Friday's. What would the select look like?

If I stored just the ranges like below am I really any better off?
OCT. 18 - 22, 2004
OCT. 25 - 29, 2004
NOV. 1 - 5, 2004
NOV. 8 - 12, 2004
NOV. 15 - 19, 2004
NOV. 22 - 26, 2004

Mike
 
A

Aaron [SQL Server MVP]

It's not the size. I'm just not sure of what to store in the table. If I
store everyday the only ones I am concerned with is the Monday's and
Friday's. What would the select look like?

Well, presumably you would have a calculated column that says "this is a
workday", then:

WHERE calendar.isWorkDay=1
If I stored just the ranges like below am I really any better off?

Not really, I don't think. Later you might find you want to use the
calendar for other things, like seminars (which may run into a Saturday) or
expense reports, that kind of thing. Also, it's not just weekdays you
should be concerned about, doesn't your company have any holidays where a
Monday or a Friday is NOT considered a normal workday? This is something
that with VBScript alone, you would have to have a big ugly case statement
or iterate through an array.

I think if you read through the article a little more thoroughly you'll see
the advantages of doing this kind of thing in the database...

A
 
M

Mike D

Aaron said:
Well, presumably you would have a calculated column that says "this is a
workday", then:

WHERE calendar.isWorkDay=1


Not really, I don't think. Later you might find you want to use the
calendar for other things, like seminars (which may run into a Saturday) or
expense reports, that kind of thing. Also, it's not just weekdays you
should be concerned about, doesn't your company have any holidays where a
Monday or a Friday is NOT considered a normal workday? This is something
that with VBScript alone, you would have to have a big ugly case statement
or iterate through an array.

I think if you read through the article a little more thoroughly you'll see
the advantages of doing this kind of thing in the database...

A
Thanks again. I guess I do need to look further down the road. What I need
in this app is one thing but I could use a table like this more often.

Thanks again

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help with code 0
Taskcproblem calendar 4
Help with my responsive home page 2
Function Help 1
My boss tells me to work at home 5
Help with code plsss 0
How to increment date by week? 8
Week Number 4

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top