Solved

Microsoft OLE DB Provider for SQL Server error '80040e07'

Posted on 2008-10-24
7
1,989 Views
Last Modified: 2012-05-05
Hi there,

I'm getting the following error on a submit page asp -

Microsoft OLE DB Provider for SQL Server error '80040e07'

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

/checkout.asp, line 179

the data that is being sent is in dd/mm/yyyy format, when I try and change the code on the page I get another error, so ideally as a short term I would like to capture this and do the conversion on the database (ms sql) anyway of doing this?

thanks
0
Comment
Question by:garethtnash
[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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 3

Expert Comment

by:Blackninja2007
ID: 22795319
usually beacuse server is expecting mm/dd/yyyy and not dd/mm/yyyy.

Hope that helps
0
 

Author Comment

by:garethtnash
ID: 22795399
is there a way to change this code -
<input type="text" value="dd/mm/yy" onfocus="this.select();lcs(this)" onclick="event.cancelBubble=true;this.select();lcs(this)">
So that it inputs like -
October 24 2008 ?
Thanks
0
 
LVL 2

Expert Comment

by:fokuszg
ID: 22795481
i am not sure if i understand what are you trying to say but
you could use 3 dropdown menus with days, months, years
let user select the date
myStr= request.form("month") & "/" & request.form("day") & "/" & "/" & request.form("year")

and use cDate(myStr) that you send to mssql.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 3

Expert Comment

by:Blackninja2007
ID: 22795770
I would recommend using either a date picker control or seperate combo's for each date part.
0
 
LVL 16

Accepted Solution

by:
Steve Krile earned 500 total points
ID: 22796893
Well, if you are sure of the format - dd/mm/yyyy with exactly that number of characters - you can do text manipulation in SQL.  Treat the submitted date as a text string, then in sql pull out the parts, and put them back together again as a date....like this.


CREATE FUNCTION dbo.ConvertDate(@dateStr as varchar(20))
RETURNS datetime
AS

   BEGIN
      DECLARE @result as datetime
      DECLARE @DayParam as varchar(2)
      DECLARE @MonthParam as varchar(2)
      DECLARE @YearParam as varchar(4)

     Set @dayParam = substring(@dateStr,1,2)
     set @monthParam = subString(@dateStr,4,2)
     set @yearParam = substring(@dateStr,7,4)


     
      Set @result =  convert(datetime, @monthparam + '/' + @dayParam + '/' + @yearParam


   RETURN @result

   END











Then, in your update procedure, you can do like this:
CREATE Procedure dbo.Update (@dateStr)
UPDATE MyTable
SET Mydate = dbo.Convertdate(@dateStr)
0
 
LVL 16

Expert Comment

by:Steve Krile
ID: 22796921
But...as a warning, the other commenters are correct...handling date formats by the time it gets to SQL can be quite fragile.  Your interface really should handle all the formatting issues, and once you are submitting your data to SQL everything should be *strongly* typed.
0
 

Author Comment

by:garethtnash
ID: 22796992
thank you
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

728 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