PDA

View Full Version : If date is less than today do not display


jimthepict
07-22-03, 04:24 PM
Hi,

I am busy making a gig list page for my site, i am only learning asp but have succesfully got the results to display within a repeating region. The problem I have is (obviously) that it displays gig dates that have expired. What code can I use to display results if equal to or greater than current date? This would presumably be handle in asp as opposed to the access db? There is a gig date in db which has to be filtered somewhere to only display relevant gigs.....just not sure how at this point.

Help much appreciated, thanks.

Here is my code so far:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="lugs_gigs/connection.asp" -->
<%
Dim rsGig__MMColParam
rsGig__MMColParam = "0"
If (Request("MM_EmptyValue") <> "") Then
rsGig__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim rsGig
Dim rsGig_numRows

Set rsGig = Server.CreateObject("ADODB.Recordset")
rsGig.ActiveConnection = MM_Gigs_STRING
rsGig.Source = "SELECT * FROM qryGigs WHERE Confirmed <> " + Replace(rsGig__MMColParam, "'", "''") + " ORDER BY Gig_Date ASC"
rsGig.CursorType = 0
rsGig.CursorLocation = 2
rsGig.LockType = 1
rsGig.Open()

rsGig_numRows = 0
%>
<%
Dim rptCfGigs__numRows
Dim rptCfGigs__index

rptCfGigs__numRows = -1
rptCfGigs__index = 0
rsGig_numRows = rsGig_numRows + rptCfGigs__numRows
%>
<SCRIPT runat=SERVER language=VBSCRIPT>
function DoDateTime(str, nNamedFormat, nLCID)
dim strRet
dim nOldLCID
strRet = str
If (nLCID > -1) Then
oldLCID = Session.LCID
End If
On Error Resume Next
If (nLCID > -1) Then
Session.LCID = nLCID
End If
If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
strRet = FormatDateTime(str, nNamedFormat)
End If
If (nLCID > -1) Then
Session.LCID = oldLCID
End If
DoDateTime = strRet End Function
</SCRIPT>

<html>
<head>
<title>blah</title>
</head>

<body>

<table width="85%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div align="left">

<h3>Skelpit Lug Gigs</h3>

<p>Confirmed Gigs: (<a href="gigs_tbc.asp">Click here for gigs booked but not yet confirmed</a>)</p>

<p>TBA = To Be Arranged</p>

<% While ((rptCfGigs__numRows <> 0) AND (NOT rsGig.EOF))
%>

<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#ffffff">
<!--DWLayoutTable-->
<tr bordercolor="cccccc" bgcolor="f5f5f5">
<td height="10" colspan="3" valign="middle"><div align="center">

<p class="heading"><%= DoDateTime((rsGig.Fields.Item("Gig_Date").Value), 1, 1033) %>

</p></div></td></tr>
<tr bordercolor="ffffff" bgcolor="#ffffff">
<td width="146" height="20"><div align="center">
<p>

If (rsGig("Function") <> "" ) Then 'if db Function column is not empty then show contents%>

<%=(rsGig.Fields.Item("Function").Value)%>

<% Else %>

TBA

<% End If %>

</p>

</div></td>
<td width="196"><div align="center">

<p>

If (rsGig("Venue") <> "" ) Then 'if db Venue column is not empty then show contents%>

<%=(rsGig.Fields.Item("Venue").Value)%>

<% Else %>

TBA

<% End If %>

</p></div></td>
<td width="140"><p align="center">

<% If (rsGig("Location") <> "" ) Then 'if db Location column is not empty then show contents%>

<%=(rsGig.Fields.Item("Location").Value)%>

<% Else %>

TBA

<% End If %>

</p></td></tr>
<tr bordercolor="ffffff" bgcolor="#ffffff">
<td height="20" colspan="3"><div align="center">
<p>

From:

<% If (rsGig("StartTime") <> "" ) Then 'if db StartTime column is not empty then show contents%>

<%= DoDateTime((rsGig.Fields.Item("StartTime").Value), 4, 1033) %>

<% Else %>

TBA
<% End If %>

&nbsp;&nbsp;&nbsp;To:

<% If (rsGig("EndTime") <> "" ) Then 'if db EndTime column is not empty then show contents%>

<%= DoDateTime((rsGig.Fields.Item("EndTime").Value), 4, 1033) %>

<% Else %>

TBA

<% End If %>

</p></div></td></tr></table><br>

<%
rptCfGigs__index=rptCfGigs__index+1
rptCfGigs__numRows=rptCfGigs__numRows-1
rsGig.MoveNext()
Wend
%>

</div></td></tr></table>

</body>
</html>

<%
rsGig.Close()
Set rsGig = Nothing
%>

Shane
07-22-03, 05:08 PM
You can use the CDate function to work with this.

IE;


If CDate(RS("some_date")) >= CDate(Now) Then
' Do something
End If


I think this should work.

jimthepict
07-22-03, 05:29 PM
Thanks Shane,

I actually just got it working by putting this: ">=Date()" in the criteria box for Gig_Date in the access db qry builder.

I will try your method also......could that be placed anywhere above the repeating region?

Shane
07-22-03, 05:42 PM
Yeah, you should be able to.

But hey, if your method works, then by all means use it. Congrats.

ldnconsulting
07-27-03, 11:03 PM
The best method to use really depends on what date reference your looking to compare against. If you do it in the database, it will only work when the database is accessed. If you do it in the asp script then it will be done when the script is run. But if either date reference point is fine then use what works best for you.

caffeine
10-19-03, 11:43 PM
can i see a working version of your concert script?

i run a state wide bands page in australia, and am looking for a efficient gigs page which will not show old gigs, and which can handle multiple bands.