Link to home
Start Free TrialLog in
Avatar of Kevin Smith
Kevin SmithFlag for United States of America

asked on

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 years...how do I let the user select only the previous, current and next week from these dates?
Avatar of Chris Luttrell
Chris Luttrell
Flag of United States of America image

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.
Avatar of Kevin Smith

ASKER

Dreamweaver.  I have the drop down getting it's list of weekending date values from a recordset hitting a table in sql.
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>
<%
rs.movenext
loop
%>
</select>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Lee Wadwell
Lee Wadwell
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great answer padas and I might use that on another project, but for this situation I'm gonna go with lwadwell's.  Thanks guys!