• sanjay.dakolia (10/22/2012)


    hi i am new to sql and i have the following problem

    i am using the following query :

    select cast (1157068800 as datetime)

    but i am getting this error :

    Msg 8115, Level 16, State 2, Line 1

    Arithmetic overflow error converting expression to data type datetime.

    please help

    thanks

    sanjay

    well it depends on what 1157068800 *means* doesn't it?

    that looks a lot like a unix date, which is the # seconds since 01/01/1970:

    /*

    declare @NumSeconds int

    SET @NumSeconds = 1157068800

    select dateadd(second,@NumSeconds,'19700101')

    */

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!