Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
wrong datatype , varchar to datetime
Old 11-22-2005, 10:38 AM wrong datatype , varchar to datetime
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
I have a string which is a timestamp but when I pass it to my sql query, i get the below error.

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type varchar to datetime.

/reports/lornasReport.asp, line 76

Could anywayone tell me why this is please
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 11-22-2005, 01:11 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you provided some data that wouldn't convert

but without seeing what you sent and how would be anyones guess at why.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-23-2005, 04:46 AM
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Hi there.

This is the code i am using to create a parameter and pass.

startDate=replace(startDate, "-","")+"000000"
endDate=replace(endDate, "-","")+"235959"
timeStamp1 = startdate
timeStamp2 = endDate

'ParamString = SQLFormatOut(timeStamp1, datetime, True) & ", " & _
' SQLFormatOut(timeStamp2, datetime, True)

Set oRS = oConn.Execute("EXEC getLornasReport " ) '& ParamString
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 11-23-2005, 06:06 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Without knowing how startdate & enddate are delivered to the script and what the SP does it's impossible to say, you'll have to do the basic debugging.
You need to response.write out variables and values to ensure that you are getting and passing what values you expect.

You obviously have the paramstring creation and passsing commented out so how does the SP get the data?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-23-2005, 06:09 AM
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Startdate and endDate are simply created by
Dim startDate, endDate

Any more help would be appreciated.
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 11-23-2005, 06:13 AM
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Dim startDate, endDate ,allTotalWrap

dim timeStamp1
dim timeStamp2

if request.form("act")="go" then

startDate=request.form("date1")
endDate=request.form("date2")
startDate=replace(startDate, "-","")+"000000"
endDate=replace(endDate, "-","")+"235959"
timeStamp1 = startdate
timeStamp2 = endDate

allOrders = getAllOrders()

end if
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 11-23-2005, 06:37 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Quote:
startDate=replace(startDate, "-","")+"000000"
What exactly is the point of this? Adding multiple zeros to this will essentially do nothing.

If you are receiving a string as your date I would suggest keeping it type specific. So, you need to use a date object, to be sure the format will be correct.

Code:
dim startDate = request.form("date1")
dim endDate = request.form("date2")

startDate = CDate(startDate)
endDate = CDate(endDate)
This will either convert your string into a valid date object or throw an error.

(Keep in mind I'm not as familiar with ASP.OLD as I am with ASP.NET so please bear with my examples if they are a little off)
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 11-23-2005, 07:12 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I can see lots that can go badly wrong with the code. Especially this
Code:
startDate=request.form("date1")
endDate=request.form("date2")
You are expecting dd-mm-yy by the look of it, what happens when someone enters 21/11/05 or 21st Nov 2005 or any combination of the dozens of ways dates can be entered.

As cptnwinky says you will have to do some typecasting to get the data in the correct format.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to wrong datatype , varchar to datetime
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35912 seconds with 12 queries