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     Understanding Date calculations

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Understanding Date calculations
 Login/Join
 
<MikeBres>
posted
Hi, I'm new to FOCUS. I'm using mainframe version 7.0.8. I need some help with the date functions. I looked at the earlier post, but I guess I don't understand FOCUS well enough to get it to work for me.
So, how do I subtract one day from the current date? What is the difference between sub/add and moving a date? How do I test these calculations? The only way I know to display anything is using the BY or COMPUTE commands.
Thank You
Mike
 
Report This Post
Virtuoso
posted Hide Post
If it is a smart date that is ymd yymd
then just subtract 1 from it. Here is an example of an age calculation I had laying around to calculate an age for different terms.
Note, it creates a date of today subtracts the birth date then divides by 365.25 to get the age.
(If I wanted yesterday, i would define
Yesterday/yymd = today - 1Wink

TODAY/YYMD = '&YYMD';
BDATE/YYMD = AA010;
AGE/I3 = IF TERM EQ '993' THEN ((TODAY - BDATE)/365.25) ELSE
IF TERM EQ '983' THEN (((TODAY - BDATE)/365.25) - 1) ELSE
IF TERM EQ '973' THEN (((TODAY - BDATE)/365.25) - 2) ELSE
((TODAY - BDATE)/365.25);
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Virtuoso
posted Hide Post
Please note in my previous post there is an ampersand in front of the YYMD field. It's just not showing.
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
Mike, dates are easy once you get the idea.
there are three kinds:
Legacy: 20041120 , format I or A
Smart: 37945, the number of days elapsed since 19001231, a base date.
Date-time: a decimal value added to a type of 'smart' date (in MSAccess), or the number of milliseconds elapsed since some basedate.
Copy this and run it:
DEFINE FILE CAR
TODAY/I8YYMD WITH CAR=&YYMD ;
ATODAY/A8 =EDIT(TODAY);
SMARTTODAY/YYMD=TODAY;
ISTODAY/I8 =SMARTTODAY;
BIGBANG/I8 =19010101;
ITEMP/I8YYMD =BIGBANG;
STEMP/YYMD =ITEMP;
ISBIGBANG/I8 =STEMP;
END
-RUN
TABLE FILE CAR
PRINT TODAY ATODAY SMARTTODAY ISTODAY BIGBANG ISBIGBANG
IF RECORDLIMIT IS 1
END
--what you should see is the value underneath the smart date, this should make it clear how you can accomplish date arithmetic with a smart date but not with legacy dates.
Smart dates appear in your reports with masks, like /YYMD or /MtDY , etc. But these formats are just masks on the true 5-digit integer value of a smart date.
Now, the base date (big bang) is different on different operating systems. I'm in windows. On IBM mainframes, the base date is slightly different. In Excel, also different. but just a day or a year or something. (try this in excel...type in a date in A1, and then in an adjacent cell, type =VALUE(A1)).Experiment in your own environment. Its not critical to know, but might become critical when you're bringing data across platforms.
Unix for example uses 1/1/77 as its base date , or 'Unix epoch'. In MSAccess, If , for ex, a date value is 37945, then a date-time for high noon on that day is 37945.5, ie 50% of the way thru the day. In Focus, i think the date-type is unix-ish and is the number of milliseconds elapsed since the unix base date in zulu time. This starts to hurt my head, but you get the idea, yes?
Any help?
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
<MikeBres>
posted
Great! Yes, it helps, thank you.

Now, what about that statement in line 3 makes the date a 'smart date'? Is it the format /YYMD ??.

Oh , by the way the file CAR couldn't be accessed, so I used one I new was there.

001 DEFINE FILE EXFDAILY
002 TODAY/I8YYMD WITH FILEDATE=&YYMD ;
003 SMARTTODAY/YYMD=TODAY;
004 YESTERDAY/YYMD=SMARTTODAY-1;
005 END
006 -RUN
007 TABLE FILE EXFDAILY
008 PRINT TODAY YESTERDAY SMARTTODAY
009 IF RECORDLIMIT IS 1
010 END

Mike
 
Report This Post
Expert
posted Hide Post
oh good, glad it helped. (how can you not have the CAR file...they even have T-shirts saying "TABLE FILE CAR"...in rhinestones yet..Call up your installer and holler).

Yes /YYMD is a mask on a smart date.
The smart date has to be created...usually out of a legacy date...by going thru those edit steps. then /YYMD is the smart date, and you can slap a new mask on it, just for display purposes, but the value under the covers doesn't change.
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
<MikeBres>
posted
It worked great until i tried to use it in a query. <sigh>
Okay here's the query

00001 DEFINE FILE EXFDAILY
00002 TODAY/I8YYMD WITH FILEDATE=&YYMD;
00003 STODAY/YMD=TODAY;
00004 YESTERDAY/YMD=STODAY-1;
00005 END
00006 TABLE FILE EXFDAILY
00007 SUM FPCS TPCS
00008 COMPUTE ONTIME/D6.2=(TPCS-FPCS)/TPCS*100;
00009 IF DDISTCODE IS 800
00010 IF RECVDATE IS YESTERDAY
00011 BY DDISTCODE RECOMPUTE
00012 BY DZIP
00013 HEADING CENTER
00014 "DAILY SCORE, FOR PIECES RECIEVED ON <RECVDATE </1"
00015 END

When I run it I get this error:
> ERROR AT OR NEAR LINE 10 IN PROCEDURE EXFCDY FOCEXEC
(FOC006) THE FORMAT OF THE TEST VALUE IS INCONSISTENT WITH FIELD FORMAT:
YESTERDAY

The format for RECVDATE is:
RECVDATE YMD

I thought I had everything in the same format, yet... Help!

So confused
Mike
 
Report This Post
Guru
posted Hide Post
Yes, the /YYMD indicates that it is a date field and it will be stored in an internal date format.

Non-standard dates would have the I8YYMD or A8YYMD. In this case the YYMD just says make it look like a date when you display it.

BTW. I think you should just be able to do the following. No need to create the first field you had.

DEFINE FILE CAR
SMARTTODAY/YYMD WITH COUNTRY='&YYMD' ;
YESTERDAY/YYMD=SMARTTODAY-1;
END
-RUN
TABLE FILE CAR
PRINT SMARTTODAY YESTERDAY
IF RECORDLIMIT IS 1
END
 
Posts: 346 | Location: Melbourne Australia | Registered: April 15, 2003Report This Post
Guru
posted Hide Post
Change the

IF RECVDATE IS YESTERDAY

to

WHERE RECVDATE IS YESTERDAY

Field-to-field comparisons can only be done with a WHERE
 
Posts: 346 | Location: Melbourne Australia | Registered: April 15, 2003Report This Post
Guru
posted Hide Post
BTW.

If you are only going to use the date in a selection statement or headings and footings (not as a display column), I would do it in a Dialogue Manager variable. That way it is calculated only once. When you do it as a DEFINE you are creating the date for every row of data you select.
 
Posts: 346 | Location: Melbourne Australia | Registered: April 15, 2003Report This Post
<MikeBres>
posted
It works! Thank you folks for all your help

Mike
 
Report 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     Understanding Date calculations

Copyright © 1996-2020 Information Builders