Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Solved]Convert UNIX Timestamp to DATE

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Solved]Convert UNIX Timestamp to DATE
 Login/Join
 
Platinum Member
posted
I am getting the date from BOTLOG2 table in the UNIX Timestamp format and would like to convert that to DATE.

Used DATECVT(UDATE,'MDYY','I8MDYY') but it gives 12/31/1900.

How can I convert the Unix Timestamp to a proper date?

This message has been edited. Last edited by: WFDevConsultant,


8.2.06
Windows, All Formats
 
Posts: 184 | Registered: December 27, 2013Report This Post
Platinum Member
posted Hide Post
This is what works for me:

-SET &NOW = DT_CURRENT_DATETIME(MILLISECOND);
-SET &NOWZ = HGETZ(8,'HYYMDs');
-SET &ANOW = DT_FORMAT(&NOW,'HYYMDs');
-SET &ANOWZ = DT_FORMAT(&NOWZ,'HYYMDs');
-SET &OFFSET = DTDIFF(&NOWZ,&NOW,HOUR);
-*
DEFINE FILE wfcrest/GET_ITEMS
BASEDATE_HYYMDS/HYYMDS=HINPUT(19, '1970-01-01 00:00:00', 8, 'HYYMDS');
CREATEDON1_HYYMDS/HYYMDS=DTADD(HADD(BASEDATE_HYYMDS, 'SECONDS', CREATEDON1/1000 , 8, 'HYYMDS'),HOUR, &OFFSET*(-1));
END

You should be aware that with WebFOCUS 8203, there's a WebFOCUS Adapter which has examples and is able to integrate with the WebFOCUS Repository which includes ReportCaster.

Efrem
 
Posts: 229 | Location: New York | Registered: July 27, 2004Report This Post
Expert
posted Hide Post
Since it's a time-stamp or date-time column, you need to use date-time functions.

Try:

COMPUTE TDATE2/YYMD = HDATE(RUN_TIMESTAMP, 'YYMD');


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
Francis,
I Unix Timestamp is a numerical number representing number of seconds from January 1, 1970.


Efrem
 
Posts: 229 | Location: New York | Registered: July 27, 2004Report This Post
Platinum Member
posted Hide Post
The Timestamp data will look like this 1525818530294.

Tried both Francis and Efrem suggestions but nothing worked.

Efrem's suggestion code
RDATE2/HYYMDS=HINPUT(19, LOGGED_STAMP, 8, 'HYYMDS');
RDATE1/MDYY=HDATE(RDATE2,'MDYY');

Francis suggestion code
RDATE1/MDYY=HDATE(LOGGED_STAMP,'MDYY');


8.2.06
Windows, All Formats
 
Posts: 184 | Registered: December 27, 2013Report This Post
Expert
posted Hide Post
Thanks Efrem.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
So, is this considered "Zulu time"?

If so, then this may be helpful:

Zulu Time – How to Read the ReportCaster Schedule File

Or this?

[SOLVED] Timestamp to date conversion

There are other search results...

BOTLOG2 is in a database - so maybe the easiest way is to use a DBMS function...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Gold member
posted Hide Post
Try this:
DEFINE FILE CAR
UTIME/D13 WITH COUNTRY = 1525818530294 ;
NEWDT/HYYMDs = HADD(DT(JAN 1 1970),'ms',UTIME,8,'HYYMDs') ;
END
TABLE FILE CAR
PRINT UTIME NEWDT
IF RECORDLIMIT EQ 2
END
-RUN
-EXIT

PAGE     1
 
 
             UTIME  NEWDT                                                      
             -----  -----                                                      
 1,525,818,530,294  2018/05/08 22:28:50.294
 1,525,818,530,294  2018/05/08 22:28:50.294



Basically, add the input milliseconds to the base date of Jan 1 1970.


IBI Development
 
Posts: 61 | Registered: November 15, 2005Report This Post
Virtuoso
posted Hide Post
quote:
Originally posted by Francis Mariani:
BOTLOG2 is in a database - so maybe the easiest way is to use a DBMS function...


This is what I usually do. This also helps with DST evaluations. Sample for PostgreSQL
 DB_EXPR(to_timestamp(left(ltrim(to_char(probe_dt_unix,'99999999999999999999999999'), ' '),10)::int) at time zone 'EST5EDT'); 

All the extra stuff was because of bad data.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Platinum Member
posted Hide Post
Hi All,

First Thanks to everyone for their suggestions and the code. Edward's solution worked for us.

Once again, Thanks to all of you and happy to be part of this forum.

Thanks


8.2.06
Windows, All Formats
 
Posts: 184 | Registered: December 27, 2013Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Solved]Convert UNIX Timestamp to DATE

Copyright © 1996-2020 Information Builders