How to get weekending date in drop down?

I have a date field in an asp page that I need to show weekending.  I've already connected it to a table query that has all the weekending dates for the next couple of do I let the user select only the previous, current and next week from these dates?
Kevin SmithAsked:
Who is Participating?
Only populate it with the desired dates ... filter the rows from your table.  This clause below should do it - change the column name 'week_ending' in the below snippet to your column name.

 where abs(DATEDIFF(ww, week_ending, getdate())) <= 1

Open in new window

Chris LuttrellSenior Database ArchitectCommented:
What is your query, table structure and values, how do you have it "connected"? What do we have to work with? I could design many ways from scratch, but I assume you need to work with what you have.
Kevin SmithAuthor Commented:
Dreamweaver.  I have the drop down getting it's list of weekending date values from a recordset hitting a table in sql.
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Could be something like below. If the only reason for having a table of data is for figuring out the weekending, you can do that with vbscript.  

'assume saturday is end of the week and you want 3 dates to choose from, last saturday, this saturday and next saturday
	DaysTillSaturday= 		7 - weekday(date)
	This Week = 				dateadd("d",DaysTillSaturday,date)
	LastWeek=				dateadd("w",-1,ThisWeek)
	NextWeek=				dateadd("w",1,ThisWeek)
' create you database connection and an sql imilar to below
SQL = "Select * From tblMyDates Where datefield >= "&LastWeek&" AND datefield <= "&NextWeek

<select name="weekendingdates">
<%do until rs.eof%>
  <option value="<%=rs("datefield")%>"><%=rs("datefield")%></option>

Open in new window

Kevin SmithAuthor Commented:
Great answer padas and I might use that on another project, but for this situation I'm gonna go with lwadwell's.  Thanks guys!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.