Link to home
Start Free TrialLog in
Avatar of Stefan Motz
Stefan MotzFlag for United States of America

asked on

Select Distinct Year from Date

I would like to do a select distinct in a dropdown menu from a date field, but return only the Year, not the full date. The attached code returns all dates once, but I'd like returned only the year.
Thanks for your help.
<%
sql="SELECT distinct(OccDate) FROM Compliments"
Set rsYears = conn.Execute(sql)
%>

<select name="myYear">
<option></option>
<%
Do While Not rsYears.EOF
Response.Write "<option>"& rsYears("OccDate") &"</option>"
rsYears.MoveNext
Loop
Response.Write "</select>"
%>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of chaau
chaau
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stefan Motz

ASKER

This is perfect, thank you very much!