Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    5

    Unanswered: RS Disply And ASP Formatting

    I have an article db that currently shows one article based on the most current Active date “CurrDate(Now)”
    is my function to find the most current article. I would like to display the most current article for each “ArticleZone” in the db.

    For example my asp page would look something like this:
    <%=rsNews.Fields("ArticleZone=3")%><br>
    <%=rsNews.Fields("ArticleZone=1")%> ect…


    Table is named Articles and looks like this

    ID, ArticleZone, ArticleActive, ArticleData
    ---------------------------------------------------------
    1, 4, 11/25/2003, text/html content
    2, 3, 10/24/2003, text/html content
    3, 1, 12/22/2003, text/html content


    SQL = "SELECT * FROM Articles WHERE ArticleActive <= " & CurrDate(Now) & " ORDER BY ArticleActive DESC"

    I hope this is clear, Thanks mossimo

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Try the following:

    select max(articlearchive),articlezone from articles group by articlezone

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    How will select the most recent article if multiples exist for the same date and articlezone ?

  4. #4
    Join Date
    Nov 2003
    Posts
    5
    First post on a new board and I abandon it for a month.
    What can I say there’s no internet in jail. Don’t worry I’m a bad guy
    I just forgot to pay my taxes for a few decades so Uncle Sam wasn’t too happy.

    Thanks rneale for the reply, you had asked:

    How will select the most recent article if multiples exist for the same date and articlezone ?

    Well the answer to both our questions was more than just a SQL Statement.
    Here is the completed working script it’s pretty simple. I left out the include file that handles article selection,
    its function “SQLDate(Now)” is called from the SQL Statement in the script and compares the current date with the each articles active date.


    <!-- #include file="SQLDate.asp" -->
    <%
    Sub WriteZoneData(zone)

    Select Case zone
    Case 1
    strZone = "zone1"
    Case 2
    strZone = "zone2"
    Case 3
    strZone = "zone3"
    Case Else
    strZone = ""
    End Select

    SQL = "SELECT * FROM Articles WHERE ActiveDate <= "&SQLDate(Now)&" _
    & "AND ArticleZone = '"&strZone&"' ORDER BY ActiveDate DESC"

    If strZone <> "" Then

    OpenDB sconArticles
    If Not Rs.EOF Then
    Response.Write(Rs("ArticleName") And Rs("ArticleData"))
    Else
    Response.Write "No Articles Found"
    End If
    CloseDB
    End Sub
    %>

    Disply the records
    <%WriteZoneData(1)%>
    <br>
    <%WriteZoneData(2)%>
    <br>
    <%WriteZoneData(3)%>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •