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] Converting a numeric timestamp value to a datetime

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Converting a numeric timestamp value to a datetime
 Login/Join
 
Virtuoso
posted
I'm doing some reporting on the ReportCaster BOTLOG tables and I'm running into a time-zone issue.

The next runtime for a schedule is stored as a number in msec's since 1970-01-01 00:00:00 GMT. I need to calculate the next runtime as a date in our time zone (CET).

I got close, but the result is in GMT:
DEFINE FILE BOTSCHED
	EPOCH/HYYMDS = DT(19700101 00:00:00Z);
	NEXTRUNTS/HYYMDS = HADD(EPOCH, 'ms', NEXTRUNTIME, 8, NEXTRUNTS);
END
TABLE FILE BOTSCHED
PRINT NEXTRUNTIME EPOCH NEXTRUNTS
WHERE READLIMIT EQ 5;
END


This is giving runtimes in GMT, which is currently 1 hour early.

Any pointer as to how I can fix this to adjust for our server time zone/DST?

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Master
posted Hide Post
Hi,

Check at this Tip provided by Susannah on Zulu Time - How to Read the reportcaster schedule File.

http://www.informationbuilders...port/developers/zulu

This might help you.

Thanks,
Ram
 
Posts: 542 | Location: Dearborn, MI | Registered: June 03, 2009Report This Post
Virtuoso
posted Hide Post
Thanks for the link.

However, it looks like I already came up with basically the same code that Susannah describes - she uses an amper-variable to set the timesone offset, which of course needs to be adjusted (manually!) every time DST changes.

There is a link to another article in there (http://www.informationbuilders.com/support/developers/timezone) that describes how to obtain the time zone information in Windows by reading the registry. But really, do I have to read the registry and convert the resulting hexadecimal value just to determine which time zone offset our server has?!? That seems a bit complicated (and inefficient)...

It seems to me that the easiest solution would be to obtain the timezone offset from the database that contains the report caster tables. In our case, that's an MS SQL 2005 database, so we should be able to create a master file around something like this:
SELECT GETDATE() - GETUTCDATE() AS EPOCH_AT_TZ


That gives the difference between UTC and our current time zone expressed as a datetime value, which for our zone (CET) gives 1900-01-01 01:00:00.0. Note that that's based in 1900 and not 1970! We'll have to add 70 years back to get our NEXTRUNTIME dates. I'm fairly certain that offset won't impact our calculations.

That value we could then use to determine EPOCH instead of the earlier used calculation, which would give us the correct datetime value to base our NEXTRUNTIME calculations on.

First attempt

I found this topic: http://forums.informationbuild...197093906#5197093906
And as a result tried:
TABLE FILE BOTSCHED
PRINT NEXTRUNTIME
	COMPUTE DIFF_UTC/HYYMDS = SQL.GETDATE() - SQL.GETUTCDATE();

WHERE READLIMIT EQ 1;
END


Unfortunately, it gives an error:
quote:

0 ERROR AT OR NEAR LINE 3 IN PROCEDURE ADHOCRQ FOCEXEC *
(FOC36343) SQL.FUNCTION CANNOT BE USED IN CONSTANT DEFINE DIFF_UTC
(FOC009) INCOMPLETE REQUEST STATEMENT
BYPASSING TO END OF COMMAND


Not sure what's wrong there...

Second attempt

Of course, we can just execute the SQL function in SQL:
SQL SQLMSS PREPARE SQLOUT FOR
SELECT GETDATE() - GETUTCDATE() AS DIFF_UTC, ' ' AS DUMMY;
END

DEFINE FILE SQLOUT
	EPOCH_AT_TZ/HYYMDs = HADD(DIFF_UTC, 'yy', 70, 8, EPOCH_AT_TZ);
END
TABLE FILE SQLOUT
PRINT 
	EPOCH_AT_TZ
BY DUMMY
ON TABLE HOLD AS TZINFO FORMAT FOCUS INDEX DUMMY
END

JOIN DUMMY WITH NEXTRUNTIME IN BOTSCHED TO UNIQUE DUMMY IN TZINFO AS J0
DEFINE FILE BOTSCHED
	DUMMY/A1V WITH NEXTRUNTIME = ' ';
END
TABLE FILE BOTSCHED
PRINT
	EPOCH_AT_TZ
	NEXTRUNTIME
	COMPUTE NEXTRUNTS/HYYMDs = HADD(EPOCH_AT_TZ, 'ms', NEXTRUNTIME, 8, NEXTRUNTS);

BY SCHEDULEID
BY JOBDESC
WHERE READLIMIT EQ 10;
END


That seems to have done the trick!

I think for most other databases a pretty similar technique could be used.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Gold member
posted Hide Post
Hi Wep5622,

thanks for sharing the interesting approach using SQL queries to get the current UTC+x.

We currently use a "simpler" approach for a similar problem - which may also be used if you extract the actual runtime of the report (and display it in the resp. timezone - which is CE(S)T also for us):

 DEFINE FUNCTION GET_OFFSET_HOUR(DATUM/A10)
  GET_OFFSET_HOUR/I3 = IF
                      (DATUM GE '20100328' AND DATUM LT '20101031') OR
                      (DATUM GE '20110327' AND DATUM LT '20111030') OR
                      (DATUM GE '20120325' AND DATUM LT '20121028') OR
                      (DATUM GE '20130331' AND DATUM LT '20131027') OR
                      (DATUM GE '20140330' AND DATUM LT '20141026') OR
                      (DATUM GE '20150329' AND DATUM LT '20151025') OR
                      (DATUM GE '20160327' AND DATUM LT '20161030') OR
                      (DATUM GE '20170326' AND DATUM LT '20171029') OR
                      (DATUM GE '20180325' AND DATUM LT '20181028') OR
                      (DATUM GE '20190331' AND DATUM LT '20191027') OR
                      (DATUM GE '20200329' AND DATUM LT '20201025') OR
                      (DATUM GE '20210328' AND DATUM LT '20211031') OR
                      (DATUM GE '20220327' AND DATUM LT '20221030') OR
                      (DATUM GE '20230326' AND DATUM LT '20231029') OR
                      (DATUM GE '20240331' AND DATUM LT '20241027') OR
                      (DATUM GE '20250330' AND DATUM LT '20251026') OR
                      (DATUM GE '20260329' AND DATUM LT '20261025') OR
                      (DATUM GE '20270328' AND DATUM LT '20271031') OR
                      (DATUM GE '20280326' AND DATUM LT '20281029') OR
                      (DATUM GE '20290325' AND DATUM LT '20291028') OR
                      (DATUM GE '20300331' AND DATUM LT '20301027') THEN 2 ELSE 1;

END
-RUN
 


Okay, this only works between 2010-2030 - but can of course be extended if desired.
+ as I said, it'll also cope with existing entries in BOTLIB.EXECUTION_TIME etc. (in combination with Susannahs EPOCH conversion techniques).

Cheers Linne


WebFOCUS 7.7.03
 
Posts: 67 | Registered: January 05, 2011Report This Post
Expert
posted Hide Post
Just above Susannahs article on Zulu time is one by John Grey entitled Using Reg.exe to Offset Time Zones From a Windows-Based System.

There are many other articles as well which may be of interest to members. To navigate there, click "IB - Developer Center" towards the top of this page. Then locate and click on the "Tips & Techniques" link on the left under "Developer Center".

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report 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] Converting a numeric timestamp value to a datetime

Copyright © 1996-2020 Information Builders