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]Subtracting Dates to get Days Difference

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED]Subtracting Dates to get Days Difference
 Login/Join
 
Gold member
posted
I know there are a lot of discussions on this, but i haven't found dates the way they are in our system.

Our date is stored into an P9 YYYYMMDD, i would like to subtract that date from current date to get number of days, and also from another date in the same record.

Also, I'm looking to add current date to the WHERE statement in the P9 format.

Please Help.

This message has been edited. Last edited by: Joe Beydoun,


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
 
Posts: 78 | Registered: December 29, 2009Report This Post
Platinum Member
posted Hide Post
quote:
Our date is stored into an P9 YYYYMMDD, i would like to subtract that date from current date to get number of days, and also from another date in the same record.

Also, I'm looking to add current date to the WHERE statement in the P9 format.

Please Help.


use the Funtion AYMD (YYYYMMDD, amount of days, 'YYYYMMDD')


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 111 | Registered: May 12, 2011Report This Post
Gold member
posted Hide Post
How do i subtract two P9 dates or one P9 date from current date.


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
 
Posts: 78 | Registered: December 29, 2009Report This Post
Virtuoso
posted Hide Post
One method is convert your dates to SmartDates so you can add and subtract the dates with simple arithmetic.

DEFINE FILE ...
 DATE1/I8YYMD = YOUR_P9_DATE ;
 DATE2/YYMD   = DATE1 ;
 CURDATE/YYMD = '&YYMD';
 DATEDIFF/I5  = CURDATE - DATE2 ;
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Gold member
posted Hide Post
Thanks Dan, that was very helpful.

Couple more things now:

1. I need Current date in a -SET statement to look like 05/24/2011.

2. I need to extract the time from a P15 field (date/time) that looks like this 20110524171520,
I tried an edit but i get a goofy number.


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
 
Posts: 78 | Registered: December 29, 2009Report This Post
Expert
posted Hide Post
What do you want to do with the time ?

As a text field, you could use PTOA, then EDIT with a MASK

If its needed in a Datetime field, then you will need one of the H??? functions.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Gold member
posted Hide Post
Just need it as a text for now.


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
 
Posts: 78 | Registered: December 29, 2009Report This Post
Virtuoso
posted Hide Post
For date in mm/dd/yyyy format try:

-SET &DATEVAR = &DATEMDYY ;


Regarding conversion of your numeric date-time to alphanumeric, try function FPRINT. Search this forum for FPRINT. The most recent entry will give you the syntax for FPRINT (which is apparently mostly undocumented!). After conversion to alphanumeric, you can format it with the EDIT function.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Guru
posted Hide Post
May I recommend the following:

(Almost) 1001 Ways to Work With Dates for WebFOCUS
This reference manual explains the date-related functions of WebFOCUS as well as the several, different types of dates supported by WebFOCUS. The specific functions and methods used vary depending on the type of date involved. Preview a sample of (Almost) 1001 Ways to Work With Dates for WebFOCUS.


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
 
Posts: 252 | Location: USA | Registered: April 15, 2003Report This Post
Expert
posted Hide Post
Just as Waz suggests, use a combination of PTOA to transfer your Packed decimal to Alpha and then use HINPUT -

DEFINE FILE CAR
  INPUTDT/P15  = 20110524171520;
  INPUTDTA/A17 = PTOA(INPUTDT, '(P15)', 'A17');
  DT_FROM_ALPHA/HYYMDS = HINPUT(17, INPUTDTA, 8, 'HYYMDS');
END
TABLE FILE CAR
PRINT INPUTDT
      INPUTDTH
      DT_FROM_ALPHA
   BY COUNTRY
IF RECORDLIMIT EQ 1
END

You can then use functions such as HPART to get the components, HDIFF to get differences for various components (Months, Days, Weeks etc.)

To get the current date into datetime format you can just use the same sort of DEFINE using a variable such as -
-SET &TodayH = &YYMD || EDIT(&TOD,'99$99$99');

T

This message has been edited. Last edited by: Tony A,



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
Gold member
posted Hide Post
Joe, your basic calculations can be done as follows:

DEFINE FILE CAR                          
MYP/P9 WITH COUNTRY = 20110429 ;         
MYBIG/P16 WITH COUNTRY = 20110524171520 ;
                                         
MYPD/P8YYMD = MYP ;                      
CURRD/I8YYMD WITH COUNTRY = &YYMD ;      
MYNEWD/YYMD = MYPD ;                     
MYCURR/YYMD = CURRD ;                    
MYDIFF/I6   = MYCURR - MYNEWD ;          
MYBDATE/P8 = MYBIG/1000000 ;             
MYTIME/P6 = MYBIG - (MYBDATE*1000000) ;  
END                                      
                                         
TABLE FILE CAR                           
PRINT MYP MYBIG MYBDATE MYTIME MYDIFF    
END                                      
  


Also, remember that you can directly get alpha from packed using EDIT- e.g.
  
MYA/A6 = EDIT(MYTIME) ; 


IBI Development
 
Posts: 61 | Registered: November 15, 2005Report This Post
Gold member
posted Hide Post
Thanks Everyone, I used everything I got here and was able to accomplish all requirements.

Much Appreciated!!!

Only thing is, the EDIT did not work to extract packed to alpha, had to use PTOA.


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
 
Posts: 78 | Registered: December 29, 2009Report 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]Subtracting Dates to get Days Difference

Copyright © 1996-2020 Information Builders