Solved

800a01a8 Error - Object required: 'Date'

Posted on 2004-10-05
4
650 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 125 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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 information …
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 video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now