0

Please see the DDL below:

CREATE TABLE TestDate (bookingdate datetime)
INSERT INTO TestDate VALUES ('2013-10-04')

Please see the ADODB recordset below:

rs.open "SELECT bookingdate FROM TestDate"
If rs("bookingdate") > dateadd("yyyy", -6, Now)
  msgbox("test")
end if

The msgbox always appears regardless of what the date in the database is.

I believe I have to do this:

If datevalue(rs("bookingdate")) > dateadd("yyyy", -6, Now)
  msgbox("test")
end if

Then the messagebox only appears if the booking date is within the last six years.

Is bookingdate treated as a string in the first code fragment?

I believe the following webpage would give me the answer: http://www.w3schools.com/ado/ado_datatypes.asp. However, it says Internal Server Error.

4

1 に答える 1