locked
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

Answers

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:

    SELECT
         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)

    http://technet.microsoft.com/en-us/library/ms187928.aspx

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

    datetime (Transact-SQL)

    http://msdn.microsoft.com/en-us/library/ms187819.aspx

    smalldatetime (Transact-SQL)

    http://msdn.microsoft.com/en-us/library/ms182418.aspx

    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