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] Extract month and year from date

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Extract month and year from date
 Login/Join
 
Silver Member
posted
I have a date column that displays date in the following format:
10/13/2011 13:59:49

I would like to extract only month and year from the date. What Date-Time function would work in this situation?

Thank you

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8
Windows, All Outputs
 
Posts: 29 | Registered: September 05, 2017Report This Post
Member
posted Hide Post
Hi Gagan,
The following maybe one of the way to extract the month and year from date-time component.

DEFINE FILE CAR
DATE/HYYMDS WITH CAR= HGETC(10,'HYYMDS');
TRANSDATE_DATE/YYMD = HDATE(DATE, 'YYMD');
YEAR/YY=TRANSDATE_DATE;
MONTH/M=TRANSDATE_DATE;
END
TABLE FILE CAR
PRINT DATE TRANSDATE_DATE MONTH YEAR
BY TOP 1 CAR NOPRINT
END

HDATE converts date-time value to date format.

OR you can use FPRINT and EDIT functions,FPRINT converts date to alphanumeric and EDIT can mask unwanted values.

DEFINE FILE CAR
DATE/HYYMDS= HGETC(10,'HYYMDS');
ALPHA_DATE/A10= FPRINT(DATE,'HYYMDS','A10');
YEAR/A4=EDIT(ALPHA_DATE,'9999$$$$$$');
MONTH/A2=EDIT(ALPHA_DATE,'$$$$$99$$$');
END
TABLE FILE CAR
PRINT DATE MONTH YEAR
BY TOP 1 CAR NOPRINT
END

This message has been edited. Last edited by: Darshan Patil,
 
Posts: 10 | Location: Bangalore | Registered: July 31, 2018Report This Post
Guru
posted Hide Post
Better use DTPART in order to get SQL optimization:

DEFINE FILE ...
YEAR/I4=DTPART(DATETIMECOLUMN,YEAR);
MONTH/I2=DTPART(DATETIMECOLUMN,MONTH);
END


Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
 
Posts: 454 | Location: Europe | Registered: February 05, 2007Report This Post
Virtuoso
posted Hide Post
Below should also work with smartdate
DEFINE FILE abc
-* numeric year
THE_YEAR /YY = YourDateField;
-* numeric month
THE_MM /MONTH = YourDateField;
-* Alpha long month mixed case
THE_Month /Mtr = YourDateField;
-* Alpha long month upper case
THE_MONTH /MTR = YourDateField;
-* Alpha short month mixed case
THE_Mth /Mt = YourDateField;
-* Alpha short month upper case
THE_MTH /MT = YourDateField;
END


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Expert
posted Hide Post
Checkout hpart or hdate, as mentioned above. Are you using IA or AS? You may be able to get this info at http://localhost:8080/ibi_apphelp/index.jsp, F1 from within AS.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Virtuoso
posted Hide Post
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Gold member
posted Hide Post
@Gagan Marwah....this is the easiest and best way .....
quote:
Originally posted by MartinY:
Below should also work with smartdate
DEFINE FILE abc
-* numeric year
THE_YEAR /YY = YourDateField;
-* numeric month
THE_MM /MONTH = YourDateField;
-* Alpha long month mixed case
THE_Month /Mtr = YourDateField;
-* Alpha long month upper case
THE_MONTH /MTR = YourDateField;
-* Alpha short month mixed case
THE_Mth /Mt = YourDateField;
-* Alpha short month upper case
THE_MTH /MT = YourDateField;
END


WebFOCUS 8
Windows, All Outputs
 
Posts: 71 | Registered: January 23, 2018Report This Post
Guru
posted Hide Post
quote:
Originally posted by vinodh:
@Gagan Marwah....this is the easiest and best way


It's easy, but why do you think it's the best way?


Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
 
Posts: 454 | Location: Europe | Registered: February 05, 2007Report This Post
Expert
posted Hide Post
quote:
It's easy, but why do you think it's the best way?


... because they have never looked at the SQL trace to see how much of the code is translated to SQL! Wink

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] Extract month and year from date

Copyright © 1996-2020 Information Builders