Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Else if and then


Message #1 by "donohue ian" <ianmdonohue@c...> on Tue, 18 Feb 2003 22:39:05 -0000

Help please I am trying to set up a loop that produces the results in a
table using different colours.  The idea is that 
1) Anything that has expired is red
2) Anything that is within 5 days of expiry is orange
3) Everything else is white

Unfortunately the loops do not work and everything is produced in red or
in orange but never the combination of colours

The variables are as follows

dDate = Expired (field from database)
Today = Today
Orange = dateadd("d",+5,date())
Other = dateadd("d",+6,date())


	If dDate > Today Then
	%>
	<td
bgcolor="#CC0033">&nbsp<%=(rscplref.Fields.Item("Expired").Value)%></
td>
	<td bgcolor="#FFFFFF"><a href="D:\Public
Services\Planning\Development 	Control\Scanned Images\<% Response.write
strResult %>\"> Link</a> 	</td>

	<%
	Else If dDate < orange Then
	%>
	<td 	bgcolor="#FFCC00">&nbsp<%=(rscplref.Fields.Item("Expired
").Value)%></	td>
	<td bgcolor="#FFFFFF"><a href="D:\Public
Services\Planning\Development 	Control\Scanned Images\<% Response.write
strResult %>\"> Link</a> 	</td>

	<%
	Else If orange < other Then
	'if 
	%>
	<td>&nbsp<%=(rscplref.Fields.Item("Expired ").Value)%></td>
	<td><a href="D:\Public Services\Planning\Development
Control\Scanned 	Images\<% Response.write  strResult %>\"> 
      Link</a> </td>
  	</tr>
  	<%
   	end if
   	end if
   	End if
   	Repeat1__index=Repeat1__index+1
  	Repeat1__numRows=Repeat1__numRows-1
  	rscplref.MoveNext()
  	Wend

	Thanks

	Ian

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 1/27/2003
 

Message #2 by "Paul Douglas" <pdouglas@t...> on Wed, 19 Feb 2003 09:46:55 +1100
Hi Ian - I might be wrong but you might find that you actually need 
"Elseif" as opposed to "Else If" - ie remove the space - I THINK that's 
the proper syntax for the elseif statement - otherwise you're getting 
multiple If's rather than one accumulated If-ElseIf......
Cheers
-----Original Message-----
From: donohue ian [mailto:ianmdonohue@c...]
Sent: Wednesday, 19 February 2003 9:39 AM
To: ASP Databases
Subject: [asp_databases] Else if and then




Help please I am trying to set up a loop that produces the results in a
table using different colours.  The idea is that
1) Anything that has expired is red
2) Anything that is within 5 days of expiry is orange
3) Everything else is white

Unfortunately the loops do not work and everything is produced in red or
in orange but never the combination of colours

The variables are as follows

dDate =3D Expired (field from database)
Today =3D Today
Orange =3D dateadd("d",+5,date())
Other =3D dateadd("d",+6,date())


	If dDate > Today Then
	%>
	<td
bgcolor=3D"#CC0033">&nbsp<%=3D(rscplref.Fields.Item("Expired").Value)%></

td>
	<td bgcolor=3D"#FFFFFF"><a href=3D"D:\Public
Services\Planning\Development 	Control\Scanned Images\<% Response.write
strResult %>\"> Link</a> 	</td>

	<%
	Else If dDate < orange Then
	%>
	<td 	bgcolor=3D"#FFCC00">&nbsp<%=3D(rscplref.Fields.Item("Expired
").Value)%></	td>
	<td bgcolor=3D"#FFFFFF"><a href=3D"D:\Public
Services\Planning\Development 	Control\Scanned Images\<% Response.write
strResult %>\"> Link</a> 	</td>

	<%
	Else If orange < other Then
	'if
	%>
	<td>&nbsp<%=3D(rscplref.Fields.Item("Expired ").Value)%></td>
	<td><a href=3D"D:\Public Services\Planning\Development
Control\Scanned 	Images\<% Response.write  strResult %>\">
      Link</a> </td>
  	</tr>
  	<%
   	end if
   	end if
   	End if
   	Repeat1__index=3DRepeat1__index+1
  	Repeat1__numRows=3DRepeat1__numRows-1
  	rscplref.MoveNext()
  	Wend

	Thanks

	Ian

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 1/27/2003



Message #3 by "Peter Foti (PeterF)" <PeterF@S...> on Tue, 18 Feb 2003 17:58:55 -0500
I don't think you can compare dates using > (less than) < (greater than).  I
think you need to use DateDiff.

Regards,
Peter Foti


> -----Original Message-----
> From: donohue ian [mailto:ianmdonohue@c...]
> Sent: Tuesday, February 18, 2003 5:39 PM
> To: ASP Databases
> Subject: [asp_databases] Else if and then
> 
> 
> 
> 
> Help please I am trying to set up a loop that produces the 
> results in a
> table using different colours.  The idea is that 
> 1) Anything that has expired is red
> 2) Anything that is within 5 days of expiry is orange
> 3) Everything else is white
> 
> Unfortunately the loops do not work and everything is 
> produced in red or
> in orange but never the combination of colours
> 
> The variables are as follows
> 
> dDate = Expired (field from database)
> Today = Today
> Orange = dateadd("d",+5,date())
> Other = dateadd("d",+6,date())
> 
> 
> 	If dDate > Today Then
> 	%>
> 	<td
> bgcolor="#CC0033">&nbsp<%=(rscplref.Fields.Item("Expired").Value)%></
> td>
> 	<td bgcolor="#FFFFFF"><a href="D:\Public
> Services\Planning\Development 	Control\Scanned 
> Images\<% Response.write
> strResult %>\"> Link</a> 	</td>
> 
> 	<%
> 	Else If dDate < orange Then
> 	%>
> 	<td 	bgcolor="#FFCC00">&nbsp<%=(rscplref.Fields.Item("Expired
> ").Value)%></	td>
> 	<td bgcolor="#FFFFFF"><a href="D:\Public
> Services\Planning\Development 	Control\Scanned 
> Images\<% Response.write
> strResult %>\"> Link</a> 	</td>
> 
> 	<%
> 	Else If orange < other Then
> 	'if 
> 	%>
> 	<td>&nbsp<%=(rscplref.Fields.Item("Expired ").Value)%></td>
> 	<td><a href="D:\Public Services\Planning\Development
> Control\Scanned 	Images\<% Response.write  strResult %>\"> 
>       Link</a> </td>
>   	</tr>
>   	<%
>    	end if
>    	end if
>    	End if
>    	Repeat1__index=Repeat1__index+1
>   	Repeat1__numRows=Repeat1__numRows-1
>   	rscplref.MoveNext()
>   	Wend
> 
> 	Thanks
> 
> 	Ian
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.449 / Virus Database: 251 - Release Date: 1/27/2003
>  
> 
> 
> 
Message #4 by "Paulo Fernandes" <paulofernandes@c...> on Tue, 18 Feb 2003 22:49:09 -0000
I would use Select Case instead...

Select Case (ddate)

	Case > Today
		Red
	Case <=3D dateadd("d",+5,date())
		Orange
	Case else
		White
End select

HTH

PauloF


-----Original Message-----
From: donohue ian [mailto:ianmdonohue@c...]
Sent: ter=E7a-feira, 18 de Fevereiro de 2003 22:39
To: ASP Databases
Subject: [asp_databases] Else if and then



Help please I am trying to set up a loop that produces the results in a
table using different colours.  The idea is that
1) Anything that has expired is red
2) Anything that is within 5 days of expiry is orange
3) Everything else is white

Unfortunately the loops do not work and everything is produced in red or
in orange but never the combination of colours

The variables are as follows

dDate =3D Expired (field from database)
Today =3D Today
Orange =3D dateadd("d",+5,date())
Other =3D dateadd("d",+6,date())


	If dDate > Today Then
	%>
	<td
bgcolor=3D"#CC0033">&nbsp<%=3D(rscplref.Fields.Item("Expired").Value)%></

td>
	<td bgcolor=3D"#FFFFFF"><a href=3D"D:\Public
Services\Planning\Development 	Control\Scanned Images\<% Response.write
strResult %>\"> Link</a> 	</td>

	<%
	Else If dDate < orange Then
	%>
	<td 	bgcolor=3D"#FFCC00">&nbsp<%=3D(rscplref.Fields.Item("Expired
").Value)%></	td>
	<td bgcolor=3D"#FFFFFF"><a href=3D"D:\Public
Services\Planning\Development 	Control\Scanned Images\<% Response.write
strResult %>\"> Link</a> 	</td>

	<%
	Else If orange < other Then
	'if
	%>
	<td>&nbsp<%=3D(rscplref.Fields.Item("Expired ").Value)%></td>
	<td><a href=3D"D:\Public Services\Planning\Development
Control\Scanned 	Images\<% Response.write  strResult %>\">
      Link</a> </td>
  	</tr>
  	<%
   	end if
   	end if
   	End if
   	Repeat1__index=3DRepeat1__index+1
  	Repeat1__numRows=3DRepeat1__numRows-1
  	rscplref.MoveNext()
  	Wend

	Thanks

	Ian

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 1/27/2003






  Return to Index