ASP If/Else how-to

azilaga

Senior member
Mar 24, 2003
756
0
0
Ok, this may be a relatively simply question, but I don't know ASP, and I need the proper syntax for a simple if/else statement. I've got a variable, "birthdate", which is a date field. The condition, in simple language, is as follows:

If birthdate is before 4/22/2002
Then apply condition 1
Else
Apply condition 2


Please help :)

Thanks!
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
I'm going to go ahead and assume VBScript ;) Most people new and old to ASP use VBScript...

Const MAX_BIRTHDATE = "4/22/2002"

If CDate(yourBirthdate) < CDate(MAX_BIRTHDATE) Then
'Yup
Else
'Nope
End If

The CDate is superfluous in the context of a variant with a subtype of VT_DATE, but I rather enjoy being explicit. VB(Script) has an overload of the comparison operators (=, <, >, ...) for dates, including a VARIANT of subtype VT_DATE as shown above.

[edit]I've just been told that the above information is "harsh" because you probably don't care about variants, overloads, etc.. If that's the case, then just ignore it. :)[/edit]
 

azilaga

Senior member
Mar 24, 2003
756
0
0
Descartes,

Thanks for the reply. Too much information is never a bad thing. I just realized one other thing...How do I specify for the birthdate = 4/22/2002 condition?

<% If birthdate < 04/22/03 Then %>
<IMG SRC="xxxxxx" WIDTH=144 height=206>
<% Else %>
<DIV ID="oDiv" STYLE="position:absolute; left:171px; top: 110px;">
<IMG SRC="xxxxxx" WIDTH=206 height=144>
</DIV>
<% End If %>

While I'm here, does anyone know of a cross-browser compatible image rotation script that turns an element 90/180/270? The solution I'm using above works only in IE5.5+.

Thanks again.