Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2002
    Posts
    165

    Unanswered: How to convert number of seconds(from January,1) in time format?

    Do You have any idea?
    Thanks a lot,Zvonimir

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Bok, Zvonko!

    You could try this:
    Code:
    SELECT FLOOR(:secs/86400) +    
    TRUNC(LAST_DAY(ADD_MONTHS(SYSDATE, -TO_CHAR(SYSDATE, 'mm'))) + 1)
    FROM dual;
    It, for :secs = 4539420, returns 22.02.2005. 12:57:00.

    The second line (trunc ...) "sets" you to Jan 1st (this year), while 86400 represents number of seconds in one day.

  3. #3
    Join Date
    Sep 2003
    Location
    Virginia, USA
    Posts
    246
    -- This tells you the number of seconds from January 1, 2005 until now.

    select (sysdate - trunc(to_date('01-JAN-2005', 'dd-MON-yyyy hh24:mi:ss')))*86400 from dual;

    This tells you the timestamp that is N seconds after January 1, 2005. It prompts you for N.

    select to_date('01-JAN-2005', 'dd-MON-yyyy hh24:mi:ss') + NUMTODSINTERVAL(&N, 'SECOND') from dual;
    MarkRem
    Author, Oracle Database 10g: From Nuts to Soup
    http://www.remidata.com/book_nuts2soup.htm

  4. #4
    Join Date
    Sep 2003
    Location
    Virginia, USA
    Posts
    246
    ooops, in the second example I meant to use TO_TIMESTAMP and not TO_DATE.

Posting Permissions

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