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     Alpha to Date Conversion

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Alpha to Date Conversion
 Login/Join
 
Platinum Member
posted
I'm using WebFOCUS 7.6.4.

I've used the Zulu Time article to convert the Epoch time to a "normal" date format. Now I need to convert that resulting A20 field to a date field that I can compare against "today" in my criteria.

I've got:
CYCLSTART/A20 = HCNVRT(FOCUSDATEST,'(HYYMDIA)',20,'A20');
CYCLSTART1/I8MDYY = DATECVT ( CYCLSTART , 'MDYY' , 'I8MDYY' ) ;
CYCLSTART2/A15 = EDIT ( CYCLSTART1 , '99/99/9999' ) ;

This gives me an error message about an invalid arguement in #1 of DATECVT.

Does anyone know how to do this conversion?

Thank you.


Production - 7.6.4
Sandbox - 7.6.4
 
Posts: 241 | Location: Bethesda, MD | Registered: August 14, 2007Report This Post
Guru
posted Hide Post
I use

 
STDATE_A1/A20= HCNVRT(STDATE2,'(HYYMDIA)',20,'A20');
STDATE_A/A20= GETTOK(SQUEEZ(20,STDATE_A1,'A20'),20,1,' ',20,'A20');

and

WHERE STDATE_A EQ '&DATEYYMD'
 


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
 
Posts: 391 | Location: California | Registered: April 14, 2003Report This Post
Expert
posted Hide Post
There are many ways to get the current date.

HGETC will give you the current Date and Time

&YYMD will get you the date when the session started (depends on how long your request takes to run).

I think it may be better to get the current date into a smart date (Format YYMD) and test against that, you can use HDATE to covert your DateTime to a Date.


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
Platinum Member
posted Hide Post
I'm still pretty new to WebFOCUS.

I know how to get today's date. My concern is whether the "CYCLSTART/A20 = HCNVRT(FOCUSDATEST,'(HYYMDIA)',20,'A20');" define results in a value that can be compared to today's date.


Production - 7.6.4
Sandbox - 7.6.4
 
Posts: 241 | Location: Bethesda, MD | Registered: August 14, 2007Report This Post
Virtuoso
posted Hide Post
If you are new to focus I would suggest you buy a very good book on dates.
"Almost 1001 Ways to work with DATES in WebFOCUS"
it's worth all the money.
And there are some great PDF files available on the Information Builders website.

An other suggestion is to upgrade your signature with information about the systems you use (version etc)




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
Hi,

If you use the following in your DEFINE command:
  
CYCLSTART/A10 = HCNVRT(FOCUSDATEST,'(HYYMD)',10,'A10');

You will get your date in alpha format with slashes
Then in your TABLE command, you can use
  
WHERE CYCLSTART EQ '&DATEYYMD';


I hope this helps you.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Platinum Member
posted Hide Post
RE: the original error ... DATECVT can take "smart dates" (which internally are integers with number of days since 1900), old alpha dates or old interger dates.
CYCLSTART is NOT a new date, it is an alpha, so datecvt knows that and tells you. This should work:
DATECVT ( CYCLSTART , 'A8MDYY' , 'I8MDYY' ) ;


Brian Suter
VP WebFOCUS Product Development
 
Posts: 200 | Location: NYC | Registered: January 02, 2007Report This Post
Virtuoso
posted Hide Post
The one issue with Daniel's solution is that you end up doing a selection on a DEFINED field, so there is a significant drop in efficiency, as those criteria cannot be passed to the DBMS. It's always better to make your variable format match the format of your real database field instead of the other way around.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Member
posted Hide Post
I get the same error ( invalid arguement in #1 of DATECVT) in 7.6.6 using:

CURDATE/HMDYY=HGETC(10,'HYYMD');
2DATE/YYMD=HDATE(CURDATE,'YYMD');
MONTH/M=DATECVT(2DATE,'YYMD','YYMD');
YEAR/YY=DATECVT(2DATE,'YYMD','YYMD');

This same code works in 7.1.6, any ideas why DATECVT has changed?
 
Posts: 13 | Registered: May 23, 2008Report This Post
Virtuoso
posted Hide Post
quote:

CURDATE/HMDYY=HGETC(10,'HYYMD');
2DATE/YYMD=HDATE(CURDATE,'YYMD');
MONTH/M=DATECVT(2DATE,'YYMD','YYMD');
YEAR/YY=DATECVT(2DATE,'YYMD','YYMD');


Perhaps it's complaining that you are not asking DATECVT to "convert" anything -- arg 2 and 3 are identical!

But once you have a date variable, you don't need DATECVT to extract month or year -- just cast it directly:

MONTH/M=2DATE;
YEAR/YY=2DATE;


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
PHawk,
if infact 2DATE is already a smart date,
then
MONTH/M = 2DATE;
YEAR/YY = 2DATE;
is all in the world you need.
Smart dates are so so so easy to format.Wink




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Member
posted Hide Post
Well I have the same situation in this date conversion:

SERYMA/A4=SUBSTR(30, F4220V1.F4220V1.SERIAL_NUMBER_1, 3, 6, 4, SERYMA);
CURDATE/MDYY=&MDY;
CURYM/YM=CURDATE;
SERYM/YM=DATECVT(SERYMA, 'A4YM', 'YM');
MTHINV/D4=CURYM-SERYM;

On our old server this would tell us how many months are between the two dates, but on the new server I got the same error about an invalid arguement in #1 of DATECVT.

I fixed this report by doing some different conversions but the root of the problems is the function DATECVT.

My changes:

SERYMA/A4=SUBSTR(30, F4220V1.F4220V1.SERIAL_NUMBER_1, 3, 6, 4, SERYMA);
CURDATE/HYYMDHA=HGETC(8, CURDATE);
YEAR/Y=HPART(CURDATE, 'YEAR', YEAR);
MONTH/M=HPART(CURDATE, 'MONTH', MONTH);
SERYYEAR/A2=EDIT(SERYMA,'99$$');
CURYYEAR/A2=EDIT(YEAR,'99');
SERYYEAR2/I2=EDIT(SERYYEAR);
CURYYEAR2/I2=EDIT(CURYYEAR);
SERYMON/A2=EDIT(SERYMA,'$$99');
CURYMON/A2=EDIT(MONTH,'99');
SERYMON2/I2=EDIT(SERYMON);
CURYMON2/I2=EDIT(CURYMON);
MTHINV/I3=((CURYYEAR2 * 12) + CURYMON2) - ((SERYYEAR2 * 12) + SERYMON2);
 
Posts: 13 | Registered: May 23, 2008Report This Post
Virtuoso
posted Hide Post
It works with A6YYM, just not A4YM (even with DFC and YRT specified in the Define). That's a bug.

- - - -
http://documentation.ibi.com/masterindex/html/html_iway...unctions76/date6.htm

Syntax: How to Convert the Format of a Date
DATECVT(date, in_format, out_format)

where:

date Is the date to be converted. ... When the conversion is performed, a legacy date obeys any DEFCENT and YRTHRESH parameter settings supplied for that field.

- - - -
But if you declare it as /A4YM, you can directly cast it to a year-month smart date without resorting to DATECVT:
DEFINE FILE CAR
 SERYMA/A4YM WITH COUNTRY=EDIT('&YMD','9999');
 SERYM/MTYY DFC 19 YRT 50 =SERYMA;
END
TABLE FILE CAR
PRINT SERYMA SERYM 
IF RECORDLIMIT EQ 1
END

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Consider this: -SET the dates which you want to pass in to the DBMS before your DEFINE or TABLE.

Example:

-SET &ReportEndDate = DATECVT(&MDYY,'I8MDYY','MDYY');
-SET &ReportEndDate = DATEADD(&ReportEndDate, 'D', -1);
-SET &ReportEndDate = DATECVT(&ReportEndDate,'MDYY','A8MDYY');
-SET &ReportEndMonth = EDIT(&ReportEndDate,'99') ;
-SET &ReportEndYear = EDIT(&ReportEndDate,'$$$$9999') ;
-* Offset the year as required
-SET &ReportEndYear = IF &ReportEndMonth GE '10' THEN &ReportEndYear - 1
- ELSE &ReportEndYear ;
-SET &ReportEndDate = IF &ReportEndMonth GE '10' THEN '0930' || &ReportEndYear
- ELSE EDIT(&ReportEndDate,'9999') || &ReportEndYear ;

The EDITs can be changed to fit whtaever format your DBMS requires. Try it, you'll like it...

And, Yes, "Almost 1001 Ways to work with DATES in WebFOCUS" is worth the money




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 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     Alpha to Date Conversion

Copyright © 1996-2020 Information Builders