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     [CLOSED] Extracting Year only from a date field

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Extracting Year only from a date field
 Login/Join
 
Member
posted
I'm trying to extract Year only from a date field.

The field is PLANNED_END format - HYYMDS

The following statement below converts PLANNED_END to a date field PLANNED_EST2
format - 2009/12/08 09:00:00.

PLANNED_EST2/HYYMDS = HADD(PLANNED_END,'hh',-4, 8, PLANNED_EST2);

What command would be used to extract the year only from PLANNED_END...ex 2009
and place it in a field PLANNED_YEAR?

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


WF 7.6.4
MS Office 2003
 
Posts: 12 | Registered: August 21, 2008Report This Post
Platinum Member
posted Hide Post
You need to use HDATE,

COMPUTE YOUR_DATE/YYMD =HDATE (PLANNED_END,'YYMD');
COMPUTE YEAR_ONLY/YY = YOUR_DATE;

Hari
WF-769


WF 7.7.02 on Windows 7
Teradata
HTML,PDF,EXCEL,AHTML
 
Posts: 165 | Registered: September 29, 2008Report This Post
Expert
posted Hide Post
This can be done in one line, using Date-Time function HNAME or HPART:

DEFINE FILE CAR
PLANNED_END/HYYMDS WITH COUNTRY = HINPUT(14, '20090509000000', 8, 'HYYMDS');
END

TABLE FILE CAR
SUM 
SALES
COMPUTE PLANNED_YEAR_ALPHA/A4 = HNAME(PLANNED_END, 'YEAR', 'A4');

COMPUTE PLANNED_YEAR_NUM/I4 = HPART(PLANNED_END, 'YEAR', 'I4');
BY COUNTRY

END


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
Member
posted Hide Post
Thanks for the response. I added both COMPUTE statements after my Define file statement.

When I reference YEAR_ONLY field in my Print statement (line 34) I get the following errors.

Could the format be incorrect on the COMPUTE statements?

(FOC259) FIELDNAME EXCEEDS ITS MAXIMUM SIZE: COMPUTE YOUR_DATE
(FOC259) FIELDNAME EXCEEDS ITS MAXIMUM SIZE: COMPUTE YEAR_ONLY
0 ERROR AT OR NEAR LINE 34 IN PROCEDURE ADHOCRQ FOCEXEC *
(FOC003) THE FIELDNAME IS NOT RECOGNIZED: YEAR_ONLY


WF 7.6.4
MS Office 2003
 
Posts: 12 | Registered: August 21, 2008Report This Post
Member
posted Hide Post
Francis, I'm getting the same error message for both Compute fields which is coded after the Define file and before the Table file statement.

(FOC259) FIELDNAME EXCEEDS ITS MAXIMUM SIZE: PLANNED_YEAR_ALPHA
(FOC259) FIELDNAME EXCEEDS ITS MAXIMUM SIZE:
PLANNED_YEAR_NUM

COMPUTE PLANNED_YEAR_ALPHA/A4 = HNAME(PLANNED_END, 'YEAR', 'A4');
COMPUTE PLANNED_YEAR_NUM/I4 = HPART(PLANNED_END, 'YEAR', 'I4');


WF 7.6.4
MS Office 2003
 
Posts: 12 | Registered: August 21, 2008Report This Post
Expert
posted Hide Post
Why do you have a DEFINE FILE statement? I need one to simulate a Date-Time (HYYMDS) field in the CAR file, but you already have a Date-Time (HYYMDS) field, PLANNED_END.

Verify that PLANNED_END is indeed a HYYMDS field.


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
Are you missing a semi-colon in the DEFINE or COMPUTE?

Error 259: The maximum size of a fieldname or alias is 66 characters. Reduce the size of the name

May be caused by a missing semi-colon or some other coding error, or if the field-name is too long.


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
quote:
Compute fields which is coded after the Define file and before the Table file statement.


Computes go within the TABLE FILE statement, not before - see my example.


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
Babinsky, I would strongly suggest reading/referencing the WebFOCUS Manual!

Here is a link to the Functions manual
Date and Time Functions

By checking this, you could have avoided the errors.


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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Extracting Year only from a date field

Copyright © 1996-2020 Information Builders