Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Posts
    19

    Unanswered: Problem With Datatime

    Hi everybody.
    I am new in SQL SERVER and I have a problem with a datetime

    I have a select. It works in a database but
    it doesn´t work in other database.

    The error is the next :

    2004-04-20 13:37:32,781 INFO [STDOUT] ConexionBDExceptionjava.sql.SQLException: [Microsoft][SQLServer JDBC Driver][SQLServer]The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value

    The select is:

    SELECT id_solicitud from solicitudes where
    fecha_apertura >= '01/03/04'
    AND fecha_apertura <= '31/03/04 23:59:59.999'
    ORDER BY fecha_apertura DESC

    Thanks for attention.
    PILAR

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    My moneys on a different collation...
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040

    Lightbulb Re: Problem With Datatime

    It looks like you are feeding the date into the select in dd/mm/yy and not mm/dd/yy. The 3/1 could be Jan 3 or Mar 1, but there will never be a 3rd day of the 31st month.

    Try this:

    SELECT id_solicitud from solicitudes where
    fecha_apertura >= '01/03/04'
    AND fecha_apertura <= convert(datetime,'31/03/04 23:59:59.999', 131)
    ORDER BY fecha_apertura DESC

    Tom

Posting Permissions

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