Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatdatetime(NOW(),2)...ODD Performance

Status
Not open for further replies.

jcroft

Programmer
Aug 23, 2001
52
US
I have a simple asp page...it looks up pishipdate in database...compares it to current system date...if pishipdate is 21 prior to current date the program is supposed to list those purchase orders.

When I do a response.write this error is produced:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'nowtemp'

/ifmchina/unifactory/datedifftest2.asp, line 56
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If I leave the response.write out I get this error:

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'madtemp'

/ifmchina/unifactory/datedifftest2.asp, line 56
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Below is the code.....any suggestions will be appreciated

******************************************************

<%Response.buffer = true

'connection definitions
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET CONN = server.CreateObject(&quot;ADODB.connection&quot;)
Set rsdsn = Server.CreateObject(&quot;ADODB.Recordset&quot;)
CONNSTR = &quot;DSN=PSPLUSHDR&quot;
CONN.Open CONNSTR
strSQL1 = &quot;Select * FROM PSPLUSHDR ORDER BY FCODE&quot;
rsdsn.Open strSQL1, conn,1,3


%>
<!-- #INCLUDE FILE=&quot;ADOVBS.INC&quot; -->
<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE>Inventory Slippage Report</TITLE>
</HEAD>
<BODY>
<FORM method=post action=&quot;datedifftest2.asp&quot;)>
<TABLE border=1 cellspacing=0 cellpadding=0 align=&quot;center&quot; size=99%>

<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

IF rsdsn.EOF = false then 'the psl purchase order header file%>
<TR>

<TD><B><CENTER>Standard PO#</CENTER></b></TD>
<TD><B><CENTER>Customer PO#</CENTER></b></TD>
<TD><B><CENTER>MAD Date</CENTER></b></TD>
<TD><B><CENTER>Time Elapsed</CENTER></b></TD>
</TR>


<%
WHILE rsdsn.EOF = false
IF rsdsn(&quot;PIShipDate&quot;) = &quot;999999&quot; then
rsdsn(&quot;PIShipDate&quot;) = &quot;&quot;
ELSE
IF rsdsn(&quot;PIShipDate&quot;) = null then
rsdsn(&quot;PIShipDate&quot;) = &quot;&quot;
ELSE
IF rsdsn(&quot;PIShipDate&quot;) = &quot; &quot; then
rsdsn(&quot;PIShipDate&quot;) = &quot;&quot;
ELSE 'any other number
IF rsdsn(&quot;PIShipDate&quot;) <> &quot;&quot; then
pitemp = trim(rsdsn(&quot;PIShipDate&quot;))
if len(pitemp) = 5 then pitemp = &quot;0&quot; & pitemp
madtemp = left(pitemp,2) & &quot;/&quot; & MID(pitemp,3,2) & &quot;/&quot; & right(pitemp,2)
nowtemp = left(formatdatetime(NOW(),2),2) & &quot;/&quot; & MID(formatdatetime(NOW(),2),3,2) & &quot;/&quot; & right(formatdatetime(NOW(),2),2)
'Response.Write rsdsn(&quot;PONUM&quot;)
elapsedtime = datediff(&quot;D&quot;,nowtemp,madtemp)
IF elapsedtime < -20 THEN %>
<TR>
<TD><CENTER><A href=&quot;podetail.asp&quot;><%= rsdsn(&quot;PONUM&quot;)%></A></CENTER></TD>
<TD><CENTER><%= rsdsn(&quot;CPONUM&quot;)%></CENTER></TD>
<TD><CENTER><%= madtemp%></CENTER></TD>
<TD><CENTER><%=elapsedtime%> days</CENTER></TD>
</TR>
<%END IF
END IF
END IF
END IF
END IF
rsdsn.movenext
wend
ELSE%>
No MAD dates have been exceeded by 21 days at this time.
<BR><a href=&quot;<%Request.ServerVariables(&quot;HTTP_REFERER&quot;)%>&quot;>Click Here to Return to Previous Page</a>
<%END IF%>
</TABLE><%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rsdsn.Close
Response.End
%>
</FORM>
</BODY>
</HTML>
*********************************************************

 
Your offset is off one in setting nowtemp:

nowtemp = left(formatdatetime(NOW(),2),2) & &quot;/&quot; & MID(formatdatetime(NOW(),2),3,2) & &quot;/&quot; & right(formatdatetime(NOW(),2),2)

should be:

nowtemp = left(formatdatetime(NOW(),2),2) & &quot;/&quot; & MID(formatdatetime(NOW(),2),4,2) & &quot;/&quot; & right(formatdatetime(NOW(),2),2)

because otherwise your nowtemp looks like this:

10//1/01

This can be checked by doing a response.write of nowtemp before your

elapsedtime = datediff(&quot;D&quot;,nowtemp,madtemp)

line of code.
 
Thank you for responding....when I change the 3 to a 4, I get this message:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: &quot;10/50/01&quot;]'

/ifmchina/unifactory/datedifftest2.asp, line 57
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I play around with the numbers and get various wrong things, if I get it to return the correct date I then get a type mismatch error...the maddate in the database is &quot;text&quot; and the number in the system is a long integer, isn't it?......I tried &quot;maddate= clng(maddate) and got an error about the &quot;clng&quot;...do you ever get all the nuances figured out?? how long have you been coding? me-I got out of school in April,2000 and went streight to work but seem to be coming along tooooo slowely.

Thank you again.
 
what does your rsdsn(&quot;PIShipDate&quot;) look like? does it have / in it, or is it just numeric? does it include date AND time, or just date?

have you tried doing a response.write of that date field at each step of the process to see what's input and what's output from each line of code?
 
Thank you again...there was inappropriate data in the database...non dates in a date field.

Your help is appreciated.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top