473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

'800a000d' type mismatch

I've been messing with this for hours, and have been to various sites,
including Aaron's site, and am truly stumped.

The short version: in SQL Server, the 4 fields in question are datetime. I
have a page that allows users to type in the info (actually a calendar
pop-up allows me to make sure they do it in the correct format), into a
textbox.

When this page gets called up again, I want to prefill the box with the
existing data, in case they need to change it. This is where the problem
comes in. SQL Server has gone and changed the time to a format which has AM
or PM at the end. And that's fine. But this calendar deal picks up the time
without the PM. So all of a sudden, 1:30 PM becomes 1:30, which then gets
saved as 1:30 AM.

Because the calendar depends a lot on Javascript, I am not willing to change
the code too much, as I have very little JS knowledge. So I have decided to
use ASP to change the data after I have retrieved it.

Here's my code:

dtTempDate = rs("TempSolution")
str24hourDate = FormatDateTime(dtTempDate,2)
str24hourTime = FormatDateTime(dtTempDate,4)
int24hourSecond = DatePart("s",dtTempDate)

if int24hourSecond = 0 then
str24hourSecond = "00"
else
if int24hourSecond < 10 then
str24hourSecond = "0" & cstr(int24hourSecond)
else str24hourSecond = Cstr(int24hourSecond)
end if
end if

strTempSolution = str24hourDate & " " & str24hourTime & ":" &
str24hourSecond
I am getting this error:

=======
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'FormatDateTime'
=======

And the line cited is

str24hourDate = FormatDateTime(dtTempDate,2)

which is the first line where I try to do any formatting.

When I comment out that line, I just get the same error on the next line.

What's wierd is that this was working, and just stopped working. I promise I
didn't change a thing between the time it worked and when it didn't.

Any help resolving this error appreciated.



Jul 27 '05 #1
7 15770
What happens when you CDate() and IsDate() rs("TempSolution") ??

e.g.

Response.Write "CDate: " & CDate(rs("TempSolution")) & "<br>"
Response.Write "IsDate: " & IsDate(rs("TempSolution"))

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"middletree" <mi********@verywarmmail.com> wrote in message
news:#c**************@TK2MSFTNGP15.phx.gbl...
I've been messing with this for hours, and have been to various sites,
including Aaron's site, and am truly stumped.

The short version: in SQL Server, the 4 fields in question are datetime. I
have a page that allows users to type in the info (actually a calendar
pop-up allows me to make sure they do it in the correct format), into a
textbox.

When this page gets called up again, I want to prefill the box with the
existing data, in case they need to change it. This is where the problem
comes in. SQL Server has gone and changed the time to a format which has AM or PM at the end. And that's fine. But this calendar deal picks up the time without the PM. So all of a sudden, 1:30 PM becomes 1:30, which then gets
saved as 1:30 AM.

Because the calendar depends a lot on Javascript, I am not willing to change the code too much, as I have very little JS knowledge. So I have decided to use ASP to change the data after I have retrieved it.

Here's my code:

dtTempDate = rs("TempSolution")
str24hourDate = FormatDateTime(dtTempDate,2)
str24hourTime = FormatDateTime(dtTempDate,4)
int24hourSecond = DatePart("s",dtTempDate)

if int24hourSecond = 0 then
str24hourSecond = "00"
else
if int24hourSecond < 10 then
str24hourSecond = "0" & cstr(int24hourSecond)
else str24hourSecond = Cstr(int24hourSecond)
end if
end if

strTempSolution = str24hourDate & " " & str24hourTime & ":" &
str24hourSecond
I am getting this error:

=======
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'FormatDateTime'
=======

And the line cited is

str24hourDate = FormatDateTime(dtTempDate,2)

which is the first line where I try to do any formatting.

When I comment out that line, I just get the same error on the next line.

What's wierd is that this was working, and just stopped working. I promise I didn't change a thing between the time it worked and when it didn't.

Any help resolving this error appreciated.




Jul 27 '05 #2
Yeah, I guess because I didn't want to have a long post, I didn't mention
everything I had tried, but I should have at least alluded to it. I did all
kinds of things with cstr, cdate, etc. Got the same error each time. Don't
think I tried IsDate, though.
"Steven Burn" <so*******@in-time.invalid> wrote in message
news:uT**************@TK2MSFTNGP15.phx.gbl...
What happens when you CDate() and IsDate() rs("TempSolution") ??

Jul 27 '05 #3
> comes in. SQL Server has gone and changed the time to a format which has
AM
or PM at the end.
No, it has not. SQL Server does *NOT* store the datetime value in a humanly
readable format it is stored as two integers. Your query is what is
producing the format with the AM/PM on the end. If you don't want to select
that format, then you can use convert. E.g., hopefully you are using a sane
and unambiguous date format, like YYYYMMDD or YYYY-MM-DD, then you can say:

SELECT
CONVERT(CHAR(8), dateColumn, 112) + ' '
+ CONVERT(CHAR(8), dateColumn, 108)
FROM Table

This will yield YYYYMMDD HH:MM:SS. If you want YYYY-MM-DD, use 120 instead
of 112. I hope we don't have to go over, again, why MM/DD/YY or DD/MM/YY is
a horrible format and should be avoided like the plague.
if int24hourSecond = 0 then
str24hourSecond = "00"
else
if int24hourSecond < 10 then
str24hourSecond = "0" & cstr(int24hourSecond)
else str24hourSecond = Cstr(int24hourSecond)
end if
end if
Ugh. Why are you doing all this? If you have the time in a format like
YYYYMMDD HH:MM:SS, you can just say right(thatVariable,2).
What's wierd is that this was working, and just stopped
working.


If the above doesn't help, then can you change back to the original query,
and tell us what this yields?

on error resume next
response.write dtTempDate
response.write "<br>"
response.write typeName(dtTempDate)
response.write "<br>"
response.write typeName(cdate(dtTempDate))
response.end
Jul 27 '05 #4
"Aaron Bertrand [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:eu**************@tk2msftngp13.phx.gbl...
This will yield YYYYMMDD HH:MM:SS. If you want YYYY-MM-DD, use 120 instead of 112. I hope we don't have to go over, again, why MM/DD/YY or DD/MM/YY is a horrible format and should be avoided like the plague.


lol..... it is?

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
Jul 27 '05 #5
Aaron, I understand where you're coming from, but for this Intranet app, the
MM/DD/YYYY format works fine and is the preferred format for what we're
doing with the data.

I did change my select to do a CONVERT and change the format, but the
CONVERT/CAST options don't have one that works for my preferred format. The
only 24-hours one, according to BOL, have the date in the wrong order for
what I'm doing.

Having said all of that, I found out that I don't need to do all that stuff
in my previous code. It turns out that the type mismatch was a simple case
of not accounting for the possibility of a NULL value. Once I added that in,
it works fine.

James
Jul 27 '05 #6
> CONVERT/CAST options don't have one that works for my preferred format.
The
only 24-hours one, according to BOL, have the date in the wrong order for
what I'm doing.
I'm not sure I understand. The very sample I showed you converted the date
and time separately using different CONVERT statements (because I realize
the all-for-one versions are limited). So you could certainly say:

SELECT CONVERT(CHAR(10), GETDATE(), 103) + ' ' + CONVERT(CHAR(8), GETDATE(),
108)

Which will yield:

dd/mm/yyyy hh:mm:ss
It turns out that the type mismatch was a simple case
of not accounting for the possibility of a NULL value.


And this is why I asked for the information previously, about what value is
actually IN dtTempDate etc.
Jul 27 '05 #7
"Aaron Bertrand [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message

I'm not sure I understand. The very sample I showed you converted the date and time separately using different CONVERT statements (because I realize
the all-for-one versions are limited). So you could certainly say:
I think I misread that part of your post. Right before it was the part that
yielded YYYY first, and then your comment about why my format is ugly. In
between those two was the solution I needed, and I failed to catch that.
Because of an interruption as I was reading it. No excuse. My apologies.

It turns out that the type mismatch was a simple case
of not accounting for the possibility of a NULL value.


And this is why I asked for the information previously, about what value

is actually IN dtTempDate etc.


Yeah, it's because you asked for it that I realized it was null.

Pretty frustrating error message, because when I see "Type Mismatch", I am
thinking that I am trying to add 2 Social Security numbers together, or
putting alphabetic characters in an integer field, or some such thing.
Trying to display a date from a NULL value is, technically speaking, a type
mismatch, but it wasn't the first thing that came to mind. Now I know
better.
Jul 27 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jimbly | last post by:
Hello, can someone help! I am getting an error: Microsoft VBScript runtime error '800a000d Type mismatch /bps/srch-detail.asp, line 137 I didn't write this asp - I know very little about...
1
by: LJgrnl | last post by:
I've got a type mismatch error that's driving me nutty. Variable blnNoData has the initial value False. If a recordset comes back empty (both .EOF and ..BOF are true) then blnNoData is set to...
1
by: Mark | last post by:
Hi - I tried this in VS.Net, and also in the Web Matrix code below: - but I am getting a type mismatch error. The sql statement runs perfectly from within the Access Query Designer. Can anyone...
4
by: Mike | last post by:
I am getting a type mismatch error when I do a bulk insert. ---Begin Error Msg--- Server: Msg 4864, Level 16, State 1, Line 1 Bulk insert data conversion error (type mismatch) for row 1, column...
1
by: Brett | last post by:
I have a form that calls a method within a DLL. By clicking a button on the form, the DLL is instantiated and the SaveOutlookMessage() method invoked. The DLL code copies messages from Outlook to...
6
by: Howard Kaikow | last post by:
I'm doing a VB 6 project in which I am trying to protect against type mismatch errors. Is the process any different in VB .NET? Here's what I'm doing in VB 6. I have an ActiveX DLL. The...
1
by: mrmike | last post by:
Microsoft VBScript runtime error '800a000d' Type mismatch: '' /events/partyrequestsubmit.asp, line 48 47 estr = estr & "Comments/Questions: " & request("comments") & vbcrlf 48 price =...
3
by: easter | last post by:
I have inherited an ASP site and am new to ASP. Part of the site allows the client to update event information about their centre. When they try to add a new event, the following error occurs: ...
4
by: ghanson | last post by:
I have started to have problems with my code. On one server the code works fine and on another (which is the one I need to run the scrpt on) I get Microsoft VBScript runtime error '800a000d' ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.