convert RRS feed

  • Question

  • how to convert datetime datatype to small datetime datatype?

    plz let me knw as early as u can

    Wednesday, March 14, 2012 7:17 AM


All replies

  • The conversion of a datetime data type to a smalldatetime data type resulted in an out-of-range value..... getting ths error
    • Merged by LeoTang Friday, March 16, 2012 2:16 AM
    Wednesday, March 14, 2012 7:34 AM
  • Hi,

    Do you mean the small datetime in SQL Server? We can implicit convert datetime type to smalldatetime, or explicit convert it to samlldatetime by using cast or convert, for example:

         CAST('2007-05-08 12:35:29'     AS smalldatetime)
        ,CAST('2007-05-08 12:35:30'     AS smalldatetime)
        ,CAST('2007-05-08 12:59:59.998' AS smalldatetime);

    CAST and CONVERT (Transact-SQL)


    As the range of datetime is bigger than samlldatetime's, you may encounter out-of-range issue.

    datetime (Transact-SQL)


    smalldatetime (Transact-SQL)


    You must make sure the value of datetime type within the range of samlldatetime.

    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Edited by LeoTang Friday, March 16, 2012 2:45 AM
    • Marked as answer by LeoTang Wednesday, March 21, 2012 5:36 AM
    Friday, March 16, 2012 2:15 AM