stevem2004
09-09-2005, 12:31 PM
Hi, I am using the following code to find items which have a date in the past, but the script is showing an error:-
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'DateValue'
travel_expire_new.asp, line 41
This was working, but just stopped on 1st September Any Ideas why??
Line 41 is:-
dte = DateValue(rs("traveltoday") & "/" & _
rs("traveltomonth") & "/" & rs("traveltoyear"))
The rest of the code is:-
<%
dim conn, rs, strconn, strSQL, strDate
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../database/prs.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
strSQL = "SELECT * FROM carpromo WHERE promostatus = 'L';"
set rs = server.createobject("adodb.recordset")
rs.open strSQL, conn, 3, 3
Dim i, count
Dim arrIDs()
Dim dte
count = 0
rs.MoveFirst
'| Iterate through the records and add all 'soon-to-expire' ones to an array.
For i = 0 To rs.RecordCount
If Not rs.EOF Then
dte = DateValue(rs("traveltoday") & "/" & _
rs("traveltomonth") & "/" & rs("traveltoyear"))
Dim intDiff
intDiff = DateDiff("d", dte, DateAdd("d", 30, Date()))
If intDiff >= 0 And intDiff <= 30 Then
ReDim Preserve arrIDs(count)
arrIDs(count) = rs("id")
count = count + 1
End If
rs.MoveNext
End If
Next
%>
<p class="normal">If you receive an error, this means that there are no promotions expiring in the next 14 days.<br>
<%
'| If any records are expiring in the next fortnight, there ID should be listed here.
For i = 0 To UBound(arrIDs)
' Response.Write (arrIDs(i) & ", ")
Next
%>
<%
strQuery = "SELECT * FROM carpromo WHERE "
For i = 0 To UBound(arrIDs)
If i > 0 Then
strQuery = strQuery & " OR id = " & arrIDs(i)
Else
strQuery = strQuery & "id = " & arrIDs(i)
End If
Next
Set conn = Server.CreateObject("ADODB.Connection")
strConn = "DBQ=" & Server.MapPath("../database/prs.mdb") & ";" & _
"Driver={Microsoft Access Driver (*.mdb)}"
conn.Open(strConn)
Set RS = Server.CreateObject("ADODB.RecordSet")
RS.Open(strQuery), conn, 3
RS.MoveFirst
For i = 0 To RS.RecordCount
If Not RS.EOF Then
'| Print out the value of the records here.
Response.Write ("<tr align=""center""><td class=""normal""><a href=""view.asp?id=" & rs("id") & """>" & rs("id") & "</a>" & "</td><td class=""normal"">" & rs("promocode") & "</td><td class=""normal"">" & rs("txtName") & "</td><td class=""normal"">" & rs("traveltoday") & "/" & rs("traveltomonth") & "/" & rs("traveltoyear") & "</td><td class=""normal"">" & rs("country") & "</td></tr>")
RS.MoveNext
End If
Next
If RS.EOF and RS.BOF Then
Response.Write ("No Promotions expiring in next 14 days.")
End If
%>
</table>
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'DateValue'
travel_expire_new.asp, line 41
This was working, but just stopped on 1st September Any Ideas why??
Line 41 is:-
dte = DateValue(rs("traveltoday") & "/" & _
rs("traveltomonth") & "/" & rs("traveltoyear"))
The rest of the code is:-
<%
dim conn, rs, strconn, strSQL, strDate
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../database/prs.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
strSQL = "SELECT * FROM carpromo WHERE promostatus = 'L';"
set rs = server.createobject("adodb.recordset")
rs.open strSQL, conn, 3, 3
Dim i, count
Dim arrIDs()
Dim dte
count = 0
rs.MoveFirst
'| Iterate through the records and add all 'soon-to-expire' ones to an array.
For i = 0 To rs.RecordCount
If Not rs.EOF Then
dte = DateValue(rs("traveltoday") & "/" & _
rs("traveltomonth") & "/" & rs("traveltoyear"))
Dim intDiff
intDiff = DateDiff("d", dte, DateAdd("d", 30, Date()))
If intDiff >= 0 And intDiff <= 30 Then
ReDim Preserve arrIDs(count)
arrIDs(count) = rs("id")
count = count + 1
End If
rs.MoveNext
End If
Next
%>
<p class="normal">If you receive an error, this means that there are no promotions expiring in the next 14 days.<br>
<%
'| If any records are expiring in the next fortnight, there ID should be listed here.
For i = 0 To UBound(arrIDs)
' Response.Write (arrIDs(i) & ", ")
Next
%>
<%
strQuery = "SELECT * FROM carpromo WHERE "
For i = 0 To UBound(arrIDs)
If i > 0 Then
strQuery = strQuery & " OR id = " & arrIDs(i)
Else
strQuery = strQuery & "id = " & arrIDs(i)
End If
Next
Set conn = Server.CreateObject("ADODB.Connection")
strConn = "DBQ=" & Server.MapPath("../database/prs.mdb") & ";" & _
"Driver={Microsoft Access Driver (*.mdb)}"
conn.Open(strConn)
Set RS = Server.CreateObject("ADODB.RecordSet")
RS.Open(strQuery), conn, 3
RS.MoveFirst
For i = 0 To RS.RecordCount
If Not RS.EOF Then
'| Print out the value of the records here.
Response.Write ("<tr align=""center""><td class=""normal""><a href=""view.asp?id=" & rs("id") & """>" & rs("id") & "</a>" & "</td><td class=""normal"">" & rs("promocode") & "</td><td class=""normal"">" & rs("txtName") & "</td><td class=""normal"">" & rs("traveltoday") & "/" & rs("traveltomonth") & "/" & rs("traveltoyear") & "</td><td class=""normal"">" & rs("country") & "</td></tr>")
RS.MoveNext
End If
Next
If RS.EOF and RS.BOF Then
Response.Write ("No Promotions expiring in next 14 days.")
End If
%>
</table>