How to get weekending date in drop down?

Posted on 2012-08-10
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 do I let the user select only the previous, current and next week from these dates?
Question by:Kevin Smith
    LVL 26

    Expert Comment

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

    Author Comment

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

    Expert Comment

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

    LVL 25

    Accepted Solution

    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


    Author Closing Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now