Content Management and Capture

 View Only
  • 1.  How to convert a DB2 date in a human understanding format ?

    Posted Mon July 08, 2024 01:37 PM
    Edited by Manuel PAITREAULT Mon July 08, 2024 01:47 PM

    Good evening,

    some dates are encoded in a numeric way (BIGINT/SMALLINT) in the DB2 database of OnDemand :

    for example, column START_DATE of ARSSEG table (looks like 18213)

    or column POST_DATE of ARSSEG table (looks like 1648736172).

    How can I convert them in a human readable way when I request the database (in date or timestamp formats, or trunc in year/month/day etc ...) ?

    Thanks in advance

    Regards



    ------------------------------
    Manuel PAITREAULT
    ------------------------------



  • 2.  RE: How to convert a DB2 date in a human understanding format ?

    Posted Mon July 08, 2024 06:54 PM

    Hi,

    theese attributes are stored in a Unix Timestamp format (generally it represents number of seconds since Jan 01 1970. (UTC)). For example -> 1648736172 represents Thu Mar 31 2022 14:16:12 GMT+0000.

    You can convert theese timestamps for example here (but there are a lot of conversion sites online etc.) - https://www.unixtimestamp.com/

    Have a nice day!

    Petr



    ------------------------------
    Petr Slepánek
    ------------------------------



  • 3.  RE: How to convert a DB2 date in a human understanding format ?

    Posted Tue July 09, 2024 02:09 AM

    Thanks a lot for your quick reply Petr.

    I had noticed that I could convert manually and individually these numerics with IBM tool arsdate, but I would like to manipulate them directly in (PL-)SQL commands. For example, how could I select rows in a table (with a SQL where clause condition) for a specific year ?

    Thanks



    ------------------------------
    Manuel PAITREAULT
    ------------------------------



  • 4.  RE: How to convert a DB2 date in a human understanding format ?

    Posted Tue July 09, 2024 03:25 AM

    Hi Manuel,

    maybe this approach can help (eg. create a function and then use it in a SQL query):

    https://ibexoft.com/converting-oracle-date-types-and-phpunix-timestamps/

    Petr



    ------------------------------
    Petr Slepánek
    ------------------------------



  • 5.  RE: How to convert a DB2 date in a human understanding format ?

    Posted Tue July 09, 2024 03:48 AM

    The following clause looks to works :
    select (date('1970-01-01')+MyColumn days) from MyTable;

    but, curiously, this request gives me 1 day forward comparing to the effective date in OnDemand :



    ------------------------------
    Manuel PAITREAULT
    ------------------------------