If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > The conversion of a char datatype to a datetime datatype resulted in an out-of-range

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-26-04, 05:20
Mirador Mirador is offline
Registered User
 
Join Date: Jan 2004
Location: Oslo
Posts: 45
Smile The conversion of a char datatype to a datetime datatype resulted in an out-of-range

Hi Very troubled about this SQL code.. not sure what i'm doing wrong..

I have debugged so i know that the strArstall is the correct format.

Will be very happy if someone can give me a little hand here..

----- ERROR MSG -------
"The conversion of a char datatype to a datetime datatype resulted in an out-of-range datetime value"
----------------------------

--------- CODE ----------------
strSQL = "SELECT reg_date,fangenr,enavn,fnavn,fodselsnr " &_
"FROM BILDE WHERE accepted=0 and marked=0 and legal not in(1,2) and CONVERT(char(8),reg_date,4) = CONVERT(Char(8), CAST('" & strArstall & "' AS DATETIME),4) "
----------------------------------

Description :
-----------------------------------
1) Using a html form where i'm inserting ex : "28.12.03" in a field.
2) In the DB the field reg_date is "datetime".
3) Posting this to a asp page where i'm using the SQL selection as above.
4) Error msg in browser.
Reply With Quote
  #2 (permalink)  
Old 01-26-04, 07:54
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
well, there's your problem

it doesn't like the 28.12.03 format

since you are building the query in a scripting language, it should be no problem to convert the input string from the form field into standard ISO date format 2003-12-28
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On