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     [SHARING] Flexible input date handling

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SHARING] Flexible input date handling
 Login/Join
 
Virtuoso
posted
I created a few DEFINE FUNCTIONs to handle different date input formats from calendar controls and the like. The basic trick is to recognize the input format by its pattern and convert it accordingly. Having a pattern available, we also suddenly have the possibility of using DECODE to choose suitable conversion formats! Me likes...

We always use YYMD formats internally (as opposed to DMYY or MDYY), we find them convenient (and less confusing), which is why there's a function specifically converting to that output.

The output format is always without dividers (hyphens or slashes), but that omission can (probably) easily be amended with a few more functions Wink

-* Convert a given date to the desired date format.
-* For example: '01-10-2018' to format '9999-99-99'
DEFINE FUNCTION DATE2FMT(INDATE/A10, OUTFMT/A8)
	PAT/A10	= PATTERN(10, INDATE, PAT);
	MASK/A10	= DECODE PAT(
			'99-99-9999' '99$99$9999'
		,	'99/99/9999' '99$99$9999'
		,	'99999999' '99999999'
		ELSE	'9999$99$99'
	);
	FMT/A6	= DECODE PAT(
			'99-99-9999' 'A8DMYY'
		,	'99/99/9999' 'A8MDYY'
		ELSE	'A8YYMD'
	);
	STR/A10 = EDIT(INDATE, MASK);
	DATE2FMT/A10 = DATECVT(STR, FMT, OUTFMT);
END
-RUN


-* Automatically convert a given date to standard format (YYMD)
DEFINE FUNCTION DATE2STD(INDATE/A10)
	DATE2STD/A10 = DATE2FMT(INDATE, 'A8YYMD');
END
-RUN

-* Convert a given date to the desired date pattern.
DEFINE FUNCTION DATE2PATTERN(INDATE/A10, OUTPAT/A10)
	FMT/A6 = DECODE OUTPAT(
			'99-99-9999' 'A8DMYY'
		,	'99/99/9999' 'A8MDYY'
		ELSE 'A8YYMD'
	);
	DATE2PATTERN/A10 = DATE2FMT(INDATE, FMT);
END
-RUN


Additions, corrections, etc. are of course welcome.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Virtuoso
posted Hide Post
Good One


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
 
Posts: 2127 | Location: Customer Support | Registered: April 12, 2005Report 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     [SHARING] Flexible input date handling

Copyright © 1996-2020 Information Builders