Stefan Motz
asked on
Classic ASP Error when displaying time from database
Hi Experts,
I'm trying to display a time entry from my Teradata database. I format it like this:
<%=FormatDateTime(rs("Arri val_Time") ,vbshortti me)%>
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.
I'm trying to display a time entry from my Teradata database. I format it like this:
<%=FormatDateTime(rs("Arri
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hmm.
Maybe try...
If CDate(rs("Arrival_Time")) > CDate("1/1/1970")
'display time
Else
'display some message
End If
It's been a while since I've worked in classic ASP!
Maybe try...
If CDate(rs("Arrival_Time")) > CDate("1/1/1970")
'display time
Else
'display some message
End If
It's been a while since I've worked in classic ASP!
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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)
CAST(CAST(Arrival_Time AS FORMAT 'HH:MI') AS CHAR(19))
For some reason my ASP page didn't like timestamps but it works fine when casting the result as a char.
CAST(CAST(Arrival_Time AS FORMAT 'HH:MI') AS CHAR(19))
For some reason my ASP page didn't like timestamps but it works fine when casting the result as a char.
ASKER
<td><%If rs("Arrival_Time") > "1/1/1970" Then%><%=FormatDateTime(rs
All times are displayed on my ASP page, except for the ones that show as 1/1/0001 00:00:00 in the database.