![]() |
Work week
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 |
Re: Work week
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",currentMond ay,4)) incrementingMonday=currentMonday do while incrementingMonday<endingFriday Response.Write vbTab & _ "<option value=""" & incrementingMonday & """>" & _ incrementingMonday & " - " & _ DateAdd("d",4, incrementingMonday) & _ "</option>" & vbCrLf incrementingMonday=DateAdd("d",7,incrementingMonda y) Loop Response.write "</select>" %> "Mike D" <MikeD@discussions.microsoft.com> wrote in message news:264EC6E9-6755-4735-B0A3-389E27FD6130@microsoft.com... > 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 |
Re: Work week
http://www.aspfaq.com/2519
-- http://www.aspfaq.com/ (Reverse address to reply.) "Mike D" <MikeD@discussions.microsoft.com> wrote in message news:264EC6E9-6755-4735-B0A3-389E27FD6130@microsoft.com... > 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 |
Re: Work week
"TomB" wrote: > > 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",currentMond ay,4)) > incrementingMonday=currentMonday > > do while incrementingMonday<endingFriday > Response.Write vbTab & _ > "<option value=""" & incrementingMonday & """>" & _ > incrementingMonday & " - " & _ > DateAdd("d",4, incrementingMonday) & _ > "</option>" & vbCrLf > incrementingMonday=DateAdd("d",7,incrementingMonda y) > Loop > Response.write "</select>" > %> > > > > > "Mike D" <MikeD@discussions.microsoft.com> wrote in message > news:264EC6E9-6755-4735-B0A3-389E27FD6130@microsoft.com... > > 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 > 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 |
Re: Work week
"Aaron [SQL Server MVP]" wrote: > http://www.aspfaq.com/2519 > > -- > http://www.aspfaq.com/ > (Reverse address to reply.) > > > > > "Mike D" <MikeD@discussions.microsoft.com> wrote in message > news:264EC6E9-6755-4735-B0A3-389E27FD6130@microsoft.com... > > 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 > Thanks Aaron, I saw that and I am considering using one. I just haven't made up my mind how much I will need it. I will have to eventually display the date ranges in an HTML table so it would make a join easy for the display. Mike |
Re: Work week
> 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... -- http://www.aspfaq.com/ (Reverse address to reply.) |
Re: Work week
>
> 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 |
Re: Work week
> 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 |
Re: Work week
"Aaron [SQL Server MVP]" wrote: > > 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 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 |
| All times are GMT. The time now is 07:35 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.