Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2002
    Location
    India
    Posts
    37

    Unanswered: Urgent : Problem with inserting a value in a datetime column

    Hello Techies,
    I have a table say 'test' and i have a column 'dt' which is a datetime column... i am inserting a value in the following manner

    insert into test values(convert(char(10),'30-12-2002',103))

    and i am getting an error

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


    Please provide me the correct statement.

    sai

  2. #2
    Join Date
    Aug 2002
    Location
    UK
    Posts
    87
    SQL server should do an implisit convertion for you, so you don't need to use the convert function.

    thus

    insert into test values(30-12-2002)

    should do the trick ......

  3. #3
    Join Date
    Aug 2002
    Location
    India
    Posts
    37
    I did the same , no problem in inserting ...but while retrying It has given some junk value....


    insert into test values(30-12-2002)

    1 rows affected

    select * from test

    dt
    ---------------------------
    1894-07-27 00:00:00.000

    (

    What to do ?


    sai

  4. #4
    Join Date
    Aug 2002
    Location
    Wilmington, Delaware USA
    Posts
    3

    Date Format

    Use YYYY-MM-DD as the format
    instead of DD-MM-YYYY or MM-DD-YYYY.

    I've had problems with using the last two formats.

Posting Permissions

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