Solved

How to display datetime in Classic ASP

Posted on 2013-01-29
7
669 Views
Last Modified: 2013-01-29
Please take a look at the code below:

<%If IsNull(rs("SunIn")) or (rs("SunIn"))="1900-01-01 00:00:00.000" Then %>
SUN
<%else%>
<%=FormatDateTime(rs("SunIn"),vbshorttime)%>
<%end if%>

I'm trying to display the word "SUN" on my Classic ASP page when the record in the SQL Server database is null or 1900-01-01 00:00:00.000
When the record is null the word SUN is displayed correctly. My problem is that when the record is 1900-01-01 00:00:00.000 the word SUN is not displayed, instead the time is displayed like this: 00:00
How could I have SUN displayed instead? Thanks for your help.
0
Comment
Question by:baxtalo
[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
  • 3
7 Comments
 
LVL 11

Expert Comment

by:David Kroll
ID: 38831792
Just a guess, but try this:

<%If IsNull(rs("SunIn")) or (rs("SunIn")="1900-01-01 00:00:00.000") Then %>
SUN
<%else%>
<%=FormatDateTime(rs("SunIn"),vbshorttime)%>
<%end if%>


Just moved one of the ) to the end of the date
0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 38831849
<%
Mesg="SUN"
if not IsNull(rs("SunIn")) then
     if left(rs("SunIn"),4)<>"1900" then
        Mesg=FormatDateTime(rs("SunIn"),vbshorttime)
    end if
end if
response.write Mesg
%>
0
 

Author Comment

by:baxtalo
ID: 38831922
Unfortunately none of the above worked. In both cases the "1900-01-01 00:00:00.000" record was returned as "00:00"
0
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.

 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 38831980
<%
response.write "The Data is "&rs("SunIn")&"<br>"
Mesg="SUN"
if not IsNull(rs("SunIn")) then
     response.write "There is data<br>"
     if left(cstr(rs("SunIn")),4)<>"1900" then
        Mesg=FormatDateTime(rs("SunIn"),vbshorttime)
    end if
end if
response.write Mesg
%>
0
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 38831988
<%
response.write "The Data is "&rs("SunIn")&"<br>"
Mesg="SUN"
if not IsNull(rs("SunIn")) then
     response.write "There is data<br>"
     if year(rs("SunIn"))<>"1900" then
        Mesg=FormatDateTime(rs("SunIn"),vbshorttime)
    end if
end if
response.write Mesg
%>
0
 

Author Comment

by:baxtalo
ID: 38832014
The Data is 1/1/1900
There is data

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment: 'cstr'
0
 

Author Closing Comment

by:baxtalo
ID: 38832023
Oh, great...
It worked; thank you very much...
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

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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