Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Location
    Oslo
    Posts
    45

    Smile Unanswered: 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.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •