?
Solved

800a01a8 Error - Object required: 'Date'

Posted on 2004-10-05
4
Medium Priority
?
713 Views
Last Modified: 2008-01-09
I am getting an error in my code when I try to get the current date. I am getting this error:

Microsoft VBScript runtime error '800a01a8'

Object required: 'Date'

/Calendar/Calendar.asp, line 3

When I try to run this code:

<%@LANGUAGE="VBSCRIPT"%>
<%
Set curDate = Date
If Request.QueryString("month") <> "" Then
Set curMonth = Request.QueryString("month")
Else
Set curMonth = Month(curDate)
End If
If Request.QueryString("year") <> "" Then
Set curYear = Request.QueryString("year")
Else
Set curYear = Year(Date)
End If
Set firstDayofMonth = WeekDay(DateSerial(curYear, curMonth, 1))
Set firstDayofMonthName = WeekDayName(WeekDay(DateSerial(Year(curDate), Month(curDate), 1)))
Set curMonthName = MonthName(curMonth)
If curMonth >= 12 Then
Set nxtMonth = 1
Else
Set nxtMonth = curMonth + 1
End If
Set nxtMonthName = MonthName(curMonth + 1)
Set nxtYear = curYear + 1
Set lstDaylstMonth = Day(DateSerial(curYear, curMonth, 1-1))
Set lstDaylstMonthName = WeekDayName(WeekDay(lstDaylstMonth))
If curMonth <= 1 Then
Set prvMonth = 12
Else
Set prvMonth = curMonth - 1
End If
Set prvMonthName = MonthName(prvMonth)
Set prvYear = curYear - 1

Select Case curMonth
Case 1,3,5,7,8,10,12
Set numDays = 31
Case 2
If curYear/4 = int(curYear/4) Then
Set numDays = 29
Else
Set numDays = 28
End If
End Select
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><%=curMonth%> - <%=curYear%></title>

I have tested the date function on another page and it has worked fine.

here is what has worked for me so far: (every part of it has worked on this page)

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
Month: <%=Month(Date)%><br>
Year: <%=Year(Date)%><br>
Day: <%=Day(Date)%><br>
MonthName(Month): <%=MonthName(Month(Date))%><br>
First Day of Month: <%=WeekDayName(WeekDay(DateSerial(Year(Date), Month(Date), 1)))%><br>
Last Day of Last Month: <%=Day(DateSerial(Year(Date), Month(Date), 1-1))%><br>
Last Day Name of Last Month: <%=WeekDayName(WeekDay(DateSerial(Year(Date), Month(Date), 1-1)))%><br>
Date: <%=Date%>
</body>
</html>

If there is some stupid thing i am doing then I wouldn't be suprized, because i am new to the asp programing language.

Thank you for your help.
0
Comment
Question by:chadreeves1
  • 3
4 Comments
 
LVL 12

Accepted Solution

by:
kingsfan76 earned 500 total points
ID: 12232347
>>Set curDate = Date

change it to:

curDate = Date
0
 
LVL 12

Expert Comment

by:kingsfan76
ID: 12232359
"Set" is for use with object i believe (like Set rst=server.CreateObject("adodb.recordset"))
"Date" is a function, so you can't use "Set" with "Date"
Just use regular assignment statement and it should be fine.
0
 
LVL 1

Author Comment

by:chadreeves1
ID: 12232369
I knew it was something stupid. I had to remove the "Set" from all of my variables
0
 
LVL 12

Expert Comment

by:kingsfan76
ID: 12232373
p.s. you need to remove all the "Set" in your assignment statements:

example:
Set curMonth = Request.QueryString("month")
Set numDays = 28
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question