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.
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
May 01, 2008, 05:22 PM
N.Selph
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'
&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.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
May 02, 2008, 09:24 AM
ColdWhiteMilk
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
May 02, 2008, 02:51 PM
FrankDutch
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
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
May 06, 2008, 01:04 PM
Brian Suter
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
May 06, 2008, 04:03 PM
Darin Lee
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
August 12, 2008, 02:35 PM
PHawk
I get the same error ( invalid arguement in #1 of DATECVT) in 7.6.6 using:
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
August 12, 2008, 03:16 PM
susannah
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.
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
August 12, 2008, 03:18 PM
PHawk
Well I have the same situation in this date conversion:
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.
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
August 18, 2008, 12:02 PM
Doug
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