Classic ASP Error when displaying time from database

Posted on 2014-03-07
Last Modified: 2014-03-08
Hi Experts,
I'm trying to display a time entry from my Teradata database. I format it like this:
The page displays it nicely, but when the time entry in the database is
1/1/0001 00:00:00
I get an error on my ASP page:
error '80020009'

How can this problem be solved?
I appreciate your help.
Question by:romsom
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
  • 2
LVL 34

Assisted Solution

by:Paul MacDonald
Paul MacDonald earned 250 total points
ID: 39913584
Trap for a date earlier than some value, then skip displaying that date.

    If rs("Arrival_Time") > "1/1/1970"
           'display time
          'display some message
     End If

Author Comment

ID: 39913640
I've tried the following, but unfortunately it displayed the same error:

<td><%If rs("Arrival_Time") > "1/1/1970" Then%><%=FormatDateTime(rs("Arrival_Time"),vbshorttime)%><%else%>-<%end if%></td>

All times are displayed on my ASP page, except for the ones that show as 1/1/0001 00:00:00 in the database.
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39913700

Maybe try...
   If CDate(rs("Arrival_Time")) > CDate("1/1/1970")
           'display time
          'display some message
     End If

It's been a while since I've worked in classic ASP!
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.


Author Comment

ID: 39913717
I've tried it, but received the same error. When I run the query in SQL Assistant everything is returned. When I run the same on my classic ASP page, the 1/1/0001 00:00:00 values display the error.
LVL 53

Accepted Solution

Scott Fell,  EE MVE earned 250 total points
ID: 39913891
Why are you using that as a date?  Non dates should be nulls.

You could try

if isdate(rs("Arrival_Time")) then
   response.write "The time is FormatDateTime(rs("Arrival_Time"),vbshorttime)
   response.write "I don't know the time"
end if

if instr("0001",cstr(rs("Arrival_Time"))) then
   response.write "I don't know the time"  
   response.write "The time is FormatDateTime(rs("Arrival_Time"),vbshorttime) 
end if

Open in new window


Author Closing Comment

ID: 39914859
Thank you very much for your attention. It turned out that I didn't have to change anything on my ASP page. I had to change the SQL and cast Arrival_Time as a char(19)  


For some reason my ASP page didn't like timestamps but it works fine when casting the result as a char.

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Table doesn't show the lines! 3 36
Help with Classic ASP - Parameterizing Query 16 67
How do I partition this table on date? 5 55
JQuery Data Table Default Sort 2 34
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

752 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