-
Does anyone know how to compare dates in VBSCript in the format mm/dd/yyyy?
In VB just simply declare the variables as
dim a as date
dim b as date
but what do you do in VBSCript?
the following code will generate the text "a is greater than b" - obviously not true
<%
dim a,b
a= "05/23/1999"
b= "01/23/2000"
if a > b then
response.write "a is greater than b"
elseif a = b then
response.write "a is equal to b"
else
response.write "a is less than b"
end if
%>
any help is appreciated!
B
-
It can be done very easily. In your code your dates are actually strings, so all you have to do is to convert them to date:
Code:
Dim a
Dim b
a= "05/23/1999"
b= "01/23/2000"
If CDate(a) > CDate(b) Then
Response.Write "a is greater than b"
Elseif CDate(a) = CDate(b) then
Response.Write "a is equal to b"
Else
Response.Write "a is less than b"
End If
-
Brilliant - thanks for your help