Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004
    Location
    Shenzhen,Chinese
    Posts
    4

    Smile Unanswered: how can I convert seconds from 1970-01-01 00:00:00 to datetime?

    I have a int value represents the seconds from 1970-01-01 00:00:00,now I want to convert it to datetime format。
    C++ can implements this function , 'print dateadd(ss, intvalue, '1970-01-01 00:00:00')' in sql server can resolve this problem also , but is there a simple method can do same thing in sybase sql ?

  2. #2
    Join Date
    Jun 2004
    Location
    Paris, France
    Posts
    43
    yes indeed, there is a simple function in sybase which can do this...
    and it is...... dateadd too !
    (once upon a time, sqlServer and Sybase were the same product...)
    dateadd(second/ss,yourInt,'01/01/...')

  3. #3
    Join Date
    Sep 2004
    Location
    Shenzhen,Chinese
    Posts
    4

    Question I can not do that yet

    I have tried to use dateadd in sybase,but there is error as below:

    1> print dateadd(ss, 123, '1970-01-01 00:00:00')
    2> go
    Msg 102, Level 15, State 1:
    Line 1:
    在 'dateadd'附近有不正确的语法。
    1> print dateadd(ss, 123, '01/01/1970 00:00:00')
    2> go
    Msg 102, Level 15, State 1:
    Line 1:
    在 'dateadd'附近有不正确的语法。

    Have I make any mistake about format of this command ?

  4. #4
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    Don't use print; do SELECT DATEADD( ... )
    Thanks,

    Matt

  5. #5
    Join Date
    Sep 2004
    Location
    Shenzhen,Chinese
    Posts
    4

    Smile Thanks everybody very much!

    Thanks everybody very much!

Posting Permissions

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