473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Jul 19 '05 #1
8 1482

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" <Mi***@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.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

Jul 19 '05 #2
http://www.aspfaq.com/2519

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


"Mike D" <Mi***@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.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

Jul 19 '05 #3


"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" <Mi***@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.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
Jul 19 '05 #4


"Aaron [SQL Server MVP]" wrote:
http://www.aspfaq.com/2519

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


"Mike D" <Mi***@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.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
Jul 19 '05 #5
> 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.)
Jul 19 '05 #6
>
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

Jul 19 '05 #7
> 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
Jul 19 '05 #8


"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
Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
7
by: Shuffs | last post by:
Could someone, anyone please tell me what I need to amend, to get this function to take Sunday as the first day of the week? I amended the Weekday parts to vbSunday (in my code, not the code...
3
by: Douglas Buchanan | last post by:
Buttons don't work if form is opened on startup A2k If 'frmMain' is set to open by default at startup none of the buttons work. If 'frmMain' is opened from the database window then all the...
3
by: Steph. | last post by:
Hi, When I use the "Calendar.GetWeekOfYear" function (with "fr-BE" as CultureInfo and Monday as the first day of week) I get : Friday 31/12/2004 : week = 53
3
by: | last post by:
Hi!! Did Infragistics or some other company else provide a web calendar conrol with the features and look of Microsoft Outlook calendar? I mean that feature that you can choose Day / Work Week /...
10
by: Jim | last post by:
I'm sure this has been asked before but I can't find any postings. I have a table that has weekly inspections for multiple buildings. What I need to do is break these down by the week of the...
8
by: apartain | last post by:
I am working in Access for a (what I thought would be) simple Work Order and Time database. I am just starting a VB class in hopes to become a real developer, not just a pretend one. In this...
5
by: CKKwan | last post by:
Dear All, Anybody know how can I get the Work Week of a given date using CSharp? Example, in SQL Server we can get using DATEPART(ww, date); I need something equavalent. Thanks In Advance
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.