Current location: Hot Scripts Forums » Programming Languages » ASP » If date is less than today do not display


If date is less than today do not display

Reply
  #1 (permalink)  
Old 07-22-03, 03:24 PM
jimthepict jimthepict is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Scotland
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
If date is less than today do not display

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
%>
__________________
Jim Dawson
Reply With Quote
  #2 (permalink)  
Old 07-22-03, 04:08 PM
Shane Shane is offline
Coding Addict
 
Join Date: Jun 2003
Location: Maryland, US
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
You can use the CDate function to work with this.

IE;

Code:
If CDate(RS("some_date")) >= CDate(Now) Then
' Do something
End If
I think this should work.
__________________
Shane Bauer
Microsoft Certified Professional (MCP) - ASP.NET
ASP/ASP.net, C#, VB/VB.NET, PHP, Perl, SQL
Reply With Quote
  #3 (permalink)  
Old 07-22-03, 04:29 PM
jimthepict jimthepict is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Scotland
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
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?
__________________
Jim Dawson
Reply With Quote
  #4 (permalink)  
Old 07-22-03, 04:42 PM
Shane Shane is offline
Coding Addict
 
Join Date: Jun 2003
Location: Maryland, US
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah, you should be able to.

But hey, if your method works, then by all means use it. Congrats.
__________________
Shane Bauer
Microsoft Certified Professional (MCP) - ASP.NET
ASP/ASP.net, C#, VB/VB.NET, PHP, Perl, SQL
Reply With Quote
  #5 (permalink)  
Old 07-27-03, 10:03 PM
ldnconsulting ldnconsulting is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #6 (permalink)  
Old 10-19-03, 10:43 PM
caffeine caffeine is offline
New Member
 
Join Date: Jul 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date From Access 2000 Database Kaikki ASP 4 09-25-03 06:04 PM
call, array and display? irfaan PHP 5 08-09-03 05:41 PM
Print data by date perleo PHP 2 08-09-03 09:35 AM
selection of dup recs by latest date atworx Hot Scripts Forum Questions, Suggestions and Feedback 0 06-24-03 11:05 PM
Days left to certain date. Data from MySQL alfreds PHP 4 06-17-03 09:26 AM


All times are GMT -5. The time now is 02:57 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.