Question
Filtering a recordset in ASP
Hello
I'd like to do something like this - first define my Recordset as:
SELECT Name, BirthYear, (year(now()) - BirthYear) AS Age FROM Table
And then in my page I'd like to use a recordset filter to display two different lists, one of over-50s, and one of under-50s, so say something like this:
Recordset.Filter = "Age > 50"
Do while not Recordset.eof
Response.Write (Recordset("Name"))
Recordset.MoveNext
loop
Recordset.Filter = 0
and then the second one (Filter="Age < 50")
However this whole technique works if I was to filter by e.g. "BirthYear > 1950", but not if I try and use my own defined column label (Age).
Is there a way of filtering using a calculation, so that I can tie it into today's date? Or do I have to just define two separate recordsets and make the calculation at that stage?
Many thanks if you can help!
Square
I'd like to do something like this - first define my Recordset as:
SELECT Name, BirthYear, (year(now()) - BirthYear) AS Age FROM Table
And then in my page I'd like to use a recordset filter to display two different lists, one of over-50s, and one of under-50s, so say something like this:
Recordset.Filter = "Age > 50"
Do while not Recordset.eof
Response.Write (Recordset("Name"))
Recordset.MoveNext
loop
Recordset.Filter = 0
and then the second one (Filter="Age < 50")
However this whole technique works if I was to filter by e.g. "BirthYear > 1950", but not if I try and use my own defined column label (Age).
Is there a way of filtering using a calculation, so that I can tie it into today's date? Or do I have to just define two separate recordsets and make the calculation at that stage?
Many thanks if you can help!
Square
