?
Solved

How to get weekending date in drop down?

Posted on 2012-08-10
5
Medium Priority
?
459 Views
Last Modified: 2012-08-24
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?
0
Comment
Question by:Kevin Smith
5 Comments
 
LVL 27

Expert Comment

by:Chris Luttrell
ID: 38281578
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.
0
 

Author Comment

by:Kevin Smith
ID: 38281690
Dreamweaver.  I have the drop down getting it's list of weekending date values from a recordset hitting a table in sql.
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 38282894
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

0
 
LVL 25

Accepted Solution

by:
lwadwell earned 2000 total points
ID: 38286405
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

0
 

Author Closing Comment

by:Kevin Smith
ID: 38329605
Great answer padas and I might use that on another project, but for this situation I'm gonna go with lwadwell's.  Thanks guys!
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question