Work week

Discussion in 'ASP General' started by Mike D, Oct 13, 2004.

  1. Mike D

    Mike D Guest

    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
    Mike D, Oct 13, 2004
    #1
    1. Advertising

  2. Mike D

    TomB Guest

    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>"
    %>




    "Mike D" <> wrote in message
    news:...
    > 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
    TomB, Oct 13, 2004
    #2
    1. Advertising

  3. http://www.aspfaq.com/2519

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "Mike D" <> wrote in message
    news:...
    > 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
    Aaron [SQL Server MVP], Oct 13, 2004
    #3
  4. Mike D

    Mike D Guest

    "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",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>"
    > %>
    >
    >
    >
    >
    > "Mike D" <> wrote in message
    > news:...
    > > 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
    Mike D, Oct 13, 2004
    #4
  5. Mike D

    Mike D Guest

    "Aaron [SQL Server MVP]" wrote:

    > http://www.aspfaq.com/2519
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
    >
    >
    > "Mike D" <> wrote in message
    > news:...
    > > 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
    Mike D, Oct 13, 2004
    #5
  6. > 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.)
    Aaron [SQL Server MVP], Oct 13, 2004
    #6
  7. Mike D

    Mike D Guest

    >
    > 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
    Mike D, Oct 13, 2004
    #7
  8. > 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
    Aaron [SQL Server MVP], Oct 13, 2004
    #8
  9. Mike D

    Mike D Guest

    "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
    Mike D, Oct 14, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    3
    Views:
    1,826
    Alexandre
    Dec 22, 2003
  2. Guest
    Replies:
    3
    Views:
    516
    Alexandre
    Dec 22, 2003
  3. Guest
    Replies:
    3
    Views:
    1,071
    Alexandre
    Dec 22, 2003
  4. Xeno Campanoli
    Replies:
    1
    Views:
    330
    James Britt
    Jul 1, 2005
  5. SimonC
    Replies:
    13
    Views:
    324
    Dr John Stockton
    Jan 4, 2005
Loading...

Share This Page