• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ASP If/Else how-to

azilaga

Senior member
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!
 
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]
 
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.
 
Back
Top