OK so what I want to do is filter my sql query for people from ages: 14-16,11-13,and 6-10. How do I do this? Also is it possible to be achieved from a dropdownlist or radiobutton

html code

<form method='post' action=process.aspx>
<select name=agerange>
<option value='0-5'>0-5</option>
<option value='6-20'>6-20</option>
<option value='21-80'>21-80</option>
</select >
<input type=submit value=submit>
</form>

process.aspx
On pageload add this

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    //you can split agerange with hyphen and get age_from age_to in 2 array elements, i dont know syntax

    //age=Me.Request.Form("agerange").split('-')
    //we assue for e.g 
    //age[0] = 6
    //age[1] =20

    sql="select * 
        from mytable where  CASE WHEN DATEADD(YEAR, DATEDIFF (YEAR, birthdate, CURRENT_TIMESTAMP), birthdate) > CURRENT_TIMESTAMP
            THEN DATEDIFF(YEAR, birthdate, CURRENT_TIMESTAMP) - 1
            ELSE DATEDIFF(YEAR, birthdate, CURRENT_TIMESTAMP) END  BETWEEN " + AGE[0] + " AND " + AGE[1]


End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.