Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2006

    Unanswered: How to convert Milliseconds to Date in DB2?

    Hi all,

    I have a date which is represented by the number of milliseconds since January 01, 1970. I need to change this back to DATE format. Is there any built in function in DB2 to do the needed conversion ?

    In Oracle i was able to do the conversion by the following statement.

    select to_char(to_date('01/01/1970','mm/dd/yyyy'),'mm/dd/yyyy') + milliseconds/86400000) from dual;

    Note: In the above sql statement, milliseconds is the no: of milliseconds of the desired date.

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 5
    You should be able to do it with straight math:

    select date(timestamp('01/01/1970','00:00:00') + (milliseconds * 1000) microseconds) ...


  3. #3
    Join Date
    Jun 2003
    Toronto, Canada
    Provided Answers: 1
    Make sure that you account for the timezone difference - UNIX time (milliseconds since 1/1/1970) is always UTC.
    "It does not work" is not a valid problem statement.

Posting Permissions

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