0

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

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by urtrivedi
0

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

Edited by urtrivedi

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.