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

    Unanswered: Urgent :Still Hanging with the 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))

    I even tried by saying

    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.

    insert into test values(30-12-2002) ...This worked while inserting..But i was fainted when i saw the query result

    Please provide me the correct statement.

    sai

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    insert into test (dt) values ('2002-12-30')


    rudy

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    The problem is with your convert statement. You are converting the date string to a char(10) but inserting into a datetime field. Use the convert(datetime,'22/7/2002',103) instead.

Posting Permissions

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