?
Solved

800a01a8 Error - Object required: 'Date'

Posted on 2004-10-05
4
Medium Priority
?
692 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

777 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