I have a set of records for news articles.
Dates are stored dd/mm/yyyy.
How can i group the records by year within the sql query? eg:
<B>News for 2007</B>
1. blah
2. Blah
3. etc etc
<B>News for 2006</B>
1. blah
2. Blah
3. etc etc
THis is the current code that i'm using:
<%sql = "select article_id, article_title, article_text, article_path, article_date, article_source from news_article order by article_date"
Set rs = dbMain.Execute(sql)
%>
<OL>
<%If Not rs.EOF Then
Do While Not rs.EOF
Response.Write("<LI><B>" & rs(1) & "</B>")
Response.Write("<BR />" & rs(2))
Response.Write("<BR />Read this article: <a href='" & rs(3) & "' target=_blank>" & rs(1) & "</a>")
If Trim(rs(4)) <> "" Then Response.Write("<BR />Article date: " & rs(4))
If Trim(rs(5)) <> "" Then Response.Write("<BR />Source: " & rs(5))
Response.Write("<BR /><a href='newsadmin.asp?action=delete&articleid=" & rs(0) & "'>Delete this Article</a><HR color='#bccd86' /></LI>" )
rs.MoveNext
Loop
End If%>
</OL>
Dates are stored dd/mm/yyyy.
How can i group the records by year within the sql query? eg:
<B>News for 2007</B>
1. blah
2. Blah
3. etc etc
<B>News for 2006</B>
1. blah
2. Blah
3. etc etc
THis is the current code that i'm using:
<%sql = "select article_id, article_title, article_text, article_path, article_date, article_source from news_article order by article_date"
Set rs = dbMain.Execute(sql)
%>
<OL>
<%If Not rs.EOF Then
Do While Not rs.EOF
Response.Write("<LI><B>" & rs(1) & "</B>")
Response.Write("<BR />" & rs(2))
Response.Write("<BR />Read this article: <a href='" & rs(3) & "' target=_blank>" & rs(1) & "</a>")
If Trim(rs(4)) <> "" Then Response.Write("<BR />Article date: " & rs(4))
If Trim(rs(5)) <> "" Then Response.Write("<BR />Source: " & rs(5))
Response.Write("<BR /><a href='newsadmin.asp?action=delete&articleid=" & rs(0) & "'>Delete this Article</a><HR color='#bccd86' /></LI>" )
rs.MoveNext
Loop
End If%>
</OL>