Focal Point
Timestamp in webfocus reports

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2851018331

November 30, 2004, 08:36 PM
<eli>
Timestamp in webfocus reports
Hi,
I am writing webfocus reports that I want to include a date time stamp on it. How do I do that either with code or from the report painter.
November 30, 2004, 08:38 PM
susannah
take the system date and time from your operating system.
in win2k, i use the two &vars &YYMD and &TOD
for today's date and time-of-day.
e.g.
-SET &HOUR = EDIT(&TOD,'99');
-SET &M = IF &TOD GT '12.00.00' THEN 'pm' ELSE 'am';
-SET &FLAG = IF &TOD GT '13.00.00' THEN 1 ELSE 0 ;
-SET &HOUR = IF &FLAG IS 1 THEN &HOUR - 12 ELSE &HOUR ;
-SET &MINUTES = EDIT(&TOD,'$$$99');
-SET &SECONDS = EDIT(&TOD,'$$$$$$99');
-SET &TIME = &HOUR | ':' | &MINUTES | &M;
December 03, 2004, 05:36 PM
webfocuspgm
eli,
Do you mean you just want it in your heading for information ? if so in text editor you can put the following code in your heading lines.
"&DATEtrMDYY "
"&TOD"


I wasn't sure exactly what you were asking for. If neither answer is what you were looking for maybe you could give us an example....
June 09, 2006, 02:28 PM
Prarie
Since this post was a couple of releases ago....is there a different way to Timestamp the time in non-military time as Susannah has done here...that does not require so many steps?


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Hi Prairie,

Try this one,
http://techsupport.informationbuilders.com/sps/83071129.html

It looks like HGETC may do the trick.

Kevin


WF 7.6.10 / WIN-AIX
Yes...that would do it. 2 developers were trying to decide which is was more effecient... a -Set or a Define.


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
As far as effficiency goes... remember that a DEFINE is evaluated for every row of data that passes your WHERE statemements. The -SET is evaluated only once and then can be used in many places.


ttfn, kp


Access to most releases from R52x, on multiple platforms.
This is what I do:

-*-- Set friendly Report Date for footing --------------------------------------
-SET &RUN_DATEX = CHGDAT('YYMD', 'MXDYY', &YYMD, 'A17');
-SET &RUN_DATE = LCWORD(&RUN_DATEX.LENGTH, &RUN_DATEX, 'A17');
-SET &RUN_TIME = HHMMSS('A8');


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
.... or for the date component -

-SET &Run_Date = &DATEtMDYY;

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 
I was hoping IBI had something that was non-military time function....


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Hi Prarie,

When you say non-military, do you mean taking the time zone of the machine? If so there is an article by John Gray that uses reg.exe in a windows based system here in the Focus on Developers pages. This article also references the Zulu Time article by Susannah and both make excellent reading.

I have taken John's suggestion and produced a fex that you can include to obtain an offset -

-* system call to write the registry value to a file
! REG QUERY HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TIMEZONEINFORMATION /V ACTIVETIMEBIAS > TZ.TXT
-*(above must be on one line)
-* filedef the file generated so that it can be read using a -READ
APP FI TZ DISK TZ.MAS
-RUN
-WRITE TZ
-WRITE TZ FILE=TZ,SUFFIX=FIX
-WRITE TZ SEGNAME=SEG1
-WRITE TZ FIELD=DATA_KEY,,A80,A80,$
-WRITE TZ DEFINE HEX/A10 = RJUST(10,GETTOK(DATA_KEY, 128, -1, 'x', 10, 'A10'),'A10');
-WRITE TZ DEFINE HEX1A/A3 = EDIT(HEX,'$$$$$$$9$$');
-WRITE TZ DEFINE HEX2A/A3 = EDIT(HEX,'$$$$$$$$9$');
-WRITE TZ DEFINE HEX3A/A3 = EDIT(HEX,'$$$$$$$$$9');
-WRITE TZ DEFINE HEX1/I3 = IF HEX1A EQ ' ' THEN 0 ELSE IF HEX1A FROM '0' TO '9' THEN BYTVAL(HEX1A, 'I3') - 48 ELSE BYTVAL(HEX1A, 'I3') - 87 ;
-WRITE TZ DEFINE HEX2/I3 = IF HEX2A EQ ' ' THEN 0 ELSE IF HEX2A FROM '0' TO '9' THEN BYTVAL(HEX2A, 'I3') - 48 ELSE BYTVAL(HEX2A, 'I3') - 87 ;
-WRITE TZ DEFINE HEX3/I3 = IF HEX3A EQ ' ' THEN 0 ELSE IF HEX3A FROM '0' TO '9' THEN BYTVAL(HEX3A, 'I3') - 48 ELSE BYTVAL(HEX3A, 'I3') - 87 ;
-RUN
FILEDEF TZ DISK ./TZ.TXT (LRECL 80 RECFM V
-RUN

TABLE FILE TZ
PRINT COMPUTE MyOffset/D5 = ( -4096 * (HEX CONTAINS 'fffff')) + ((HEX1 * 256) + (HEX2 * 16) + HEX3);
WHERE DATA_KEY CONTAINS 'ACTIVETIMEBIAS'
ON TABLE SAVE AS HEXVALUE
END
-RUN
-* read the saved data that contains the required value
-READ HEXVALUE &Offset.A5.
-RUN


and used it in another fex using Susannah's suggestion within a reuseable function -

-SET &Time = EDIT(&TOD,'99$99');
-INCLUDE TimeZone
-SET &OFFSETHOURS =-(&Offset/60);
DEFINE FUNCTION ZULUTIME(OFFSET/A10, VALUE/D4)
NOWDATETIME_A/HYYMDS=HGETC(8, 'HYYMDS');
NOWDATETIME/HYYMDS=HADD(NOWDATETIME_A, OFFSET, VALUE, 8, 'HYYMDS');
DAYSDIFF/D8=DATEDIF('19700101', '&YYMD', 'D');
MSDIFF/D32=DAYSDIFF*24*60*60*1000;
ADDOFFSET/D12=&OFFSETHOURS*60*60*1000;
NOWMILLISEC/D12 = HTIME(8, NOWDATETIME, 'D12.2');
NEEDTOADD/D13=NOWMILLISEC+ADDOFFSET+MSDIFF;
ZULUTIME/A17=FTOA(NEEDTOADD, '(D13c)', 'A17');
END
-RUN

-SET &NextRunTime='0000000000000000000' | ZULUTIME('minute',-110);


which I use to update the BOTSCHED file as necessary.

Hope this helps.

T

p.s. I know this is a wide posting but I have left it like this purposefully so that the -write lines are not split.



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 
Based on my reading of the request, it would seem Prairie wants a value like:

YYYY/MM/DD HH:MM:SSAP

where YYYY is the year; MM is the month; DD is the day; HH is the hour; MM is the minute; SS is the second; and AP is 'AM' or 'PM'.

Assuming that is what's wanted, you can use a DEFINE with the appropriate format. If you don't reference any database fields, it is only evaluated ONCE. You can see this with a '? DEFINE', which shows that the define is NOT associated with any segment (it's global).

If you want it via Dialogue Manager, you can also get it. The first thing you need to understand, is that EVERY field stored as a Dialogue Manager value, is stored as a character string. That's why you have to work to get decimals from a calculation, as we don't know HOW MANY decimal places to keep.

So, with that said, here's how I did it:

-SET &NOW = HCNVRT(HGETC(8,'HYYMDm'),'(HYYMDSA)',30,'A30');


This is actually a subroutine call as an argument to another subroutine call. The HGETC retrieved the current date-time, as a DATE-TIME formatted field. We provide that as the FIRST argument to the HCNVRT routine, which converts a date-time field to an alpha (required by D.M. remember?).

The current time is retrieved to milliseconds, then converted to a display format with the time indicated by an AM or PM.

Hope that's what you were looking for.
sweet!
and loaded with ancillary info.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
Here's the DEFINE for time - although the DM version is more flexible.

DEFINE FILE CAR
CURRTIME/HHISA= HGETC(8,'HHISA');
END
TABLE FILE CAR
" <CURRTIME "
PRINT CAR
END
Thanks to everyone...
Focwizard...
-SET &NOW = HCNVRT(HGETC(8,'HYYMDm'),'(HYYMDSA)',30,'A30');

That's it!!

Winky


In Focus since 1993. WebFOCUS 7.7.03 Win 2003