Solved

800a01a8 Error - Object required: 'Date'

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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