× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Don,

In db2 you can convert a timestamp to unix epoch with

values( extract(epoch from timestamp('2023-04-06','06:32:00')) )

which returns 1,680,762,720


To go the other way,

 values(timestamp('1970-01-01','00:00:00') + 1680762720 seconds)

returns

 VALUES
 2023-04-06-06.32.00.000000

Notice that the first example returns 1680762720 instead of the value 1680762720000 that you specified in your email.  Assuming the value in your email is correct, then it's milliseconds instead of seconds from 1970-01-01 00:00:00, and you could use

values(timestamp('1970-01-01','00:00:00')
      + (1680762720000 / 1000) seconds)

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx
pdow@xxxxxxxxxxxxxx /


On 5/29/2023 8:57 PM, Don Brown via MIDRANGE-L wrote:
We need to process data from a non DB2 source that will be loaded into DB2
on IBMi

The dates are stored in a long format and my google skills are failing on
finding how to convert.

I can find a unix site that will convert it for me but not how to do it as
the end requirement will be to do it in RPG

For testing we are using DBeaver to access the PostGre SQL database and
while it appears from the sample that there should be functions to do this
we just get an error that the function does not exist.

Here s an example of the date

Database value: 1680762720000

This represents the following

GMT: Thursday, April 6, 2023 6:32:00 AM
local time: Thursday, April 6, 2023 4:32:00 PM GMT+10:00

I would be happy with just a standard time stamp like 06-04-2023 16:32:00

Thank you for any assistance provided.

Cheers

Don

--
This email has been scanned for computer viruses. Although MSD has taken reasonable precautions to ensure no viruses are present in this email, MSD cannot accept responsibility for any loss or damage arising from the use of this email or attachments..

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.