sql = "select distinct year(date),month(date) from nyhet order by 1,2"
set rs = connect.execute(sql)
pyear = 0
months = ""
while not rs.eof
if pyear <> clng(rs(0)) then
if months <> "" then
response.write months & "<br>"
months = ""
end if
pyear = clng(rs(0))
response.write pyear & "<br>"
response.write "-------" & "<br"
end if
if months <> "" then months = months & ", "
months = months & monthname(cint(rs(1)))
rs.movenext
wend
if months <> "" then response.write months & "<br>"
rs.close
set rs = nothing
Beroende på DBMS så får du kanske ändra på funktionerna year och month
Det är onödigt att lagra år och månad separat.