Focal Point
converting 20071108 to a Date?
November 08, 2007, 11:12 AM
Jason K.converting 20071108 to a Date?
I'm not sure where to look for information on this...
I'd like to convert a numeric field to a webfocus date in a compute/define. It's 8 digits, YYYYMMDD.
What function does this? Is there something simple like oracle's to_date? Or do I have to typecast to a string, substr out the year, month and date seperately then feed them back into a function or something?
Thanks!
Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
November 08, 2007, 11:19 AM
Francis MarianiWebFOCUS Dates are a pain - a whole book has been written on the subject.
TABLE FILE CAR
PRINT COUNTRY
COMPUTE DT1/I8 = 20071125; NOPRINT
COMPUTE DT2/I8YYMD = DT1; NOPRINT
COMPUTE DT3/YYMD = DT2;
END
DT1 is your numeric date. DT2 is the numeric date with a date format. DT3 is the date formatted field. You can do this in a DEFINE or a COMPUTE.
You can go further and convert this to a Date-Time 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
November 08, 2007, 11:29 AM
Francis MarianiDate-Time:
TABLE FILE CAR
PRINT COUNTRY
COMPUTE DT1/I8 = 20071125; NOPRINT
COMPUTE DT2/I8YYMD = DT1; NOPRINT
COMPUTE DT3/YYMD = DT2;
-*COMPUTE DT4/HYYMDS = DT3;
COMPUTE DT5/A14 = EDIT(DT2) | '000000';
COMPUTE DT6/HYYMDS = HINPUT(14, DT5, 8, 'HYYMDS');
END
You would think that the compute for DT4 would work - you want to convert a date field into a date-time field, but it doesn't work - that would be too easy.
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
November 08, 2007, 12:07 PM
GinnyJakesquote:
TABLE FILE CAR
PRINT COUNTRY
COMPUTE DT1/I8YYMD = 20071125; NOPRINT
COMPUTE DT3/YYMD = DT1;
END
For just the date, it is a simple equality. I used Francis' example and eliminated one COMPUTE.
And, as Francis also showed, date-time is a bit more convoluted.
Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
November 08, 2007, 12:21 PM
Francis MarianiYou can't eliminate the compute if there is already a numeric field that needs to be converted to a date field. The existing field has to be converted to an I8YYMD field before being converted to a date 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
November 08, 2007, 12:30 PM
Francis Marianiquote:
DATE_X/YYMD = DATECVT(&YYMD, 'I8YYMD', 'YYMD');
Yes, that would be lovely.
TABLE FILE CAR
PRINT COUNTRY
COMPUTE DT1/I8 = 20071125; NOPRINT
COMPUTE DATE_X/YYMD = DATECVT(DT1, 'I8YYMD', 'YYMD');
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
November 08, 2007, 01:50 PM
FrankDutchFrancis, never to old....
Did you read that book?
|
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 |
November 08, 2007, 01:55 PM
Jason K.good work. thanks!
Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
November 08, 2007, 02:21 PM
Francis MarianiFrank, I will read that book on my next trip on the Titanic.
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
November 08, 2007, 03:07 PM
GizmoI find it intersting that everyone seems to be obsessed with using the integer date to begin with and then converting to a smart-date, or if need be, directly to the date-timestamp using the DT function?
Why not go directly to the smart-date?
TABLE FILE CAR
SUM COMPUTE MYSMARTDATE/YYMD = '20071108';
COMPUTE MYDATESTAMP/HYYMDS = DT(20071108);
BY COUNTRY
END
Windows: WF 7.6.2: SQL Server 2008 R2 November 08, 2007, 03:10 PM
Francis MarianiWell, the original question did start with "I'd like to convert a numeric field to a webfocus date".
If you have a field in a table (that you cannot modify, or modify the master for) that contains a date, but is defined as a numeric field, you would have to do what we've been talking about here.
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
November 08, 2007, 03:16 PM
Francis MarianiAh yes, another day, another OJ trial.
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
November 08, 2007, 03:34 PM
GizmoAhhh, it does help to pay a little more attention to the origional question.
And, uhhh, OJ was never in that hotel - it's all a setup
Windows: WF 7.6.2: SQL Server 2008 R2 November 08, 2007, 03:48 PM
GizmoTom
I'ts easy...
-SET &STR = EDIT(&YYMD,'$$$$9999') || EDIT(&YYMD,'9999');
DEFINE FILE CAR
MYDATE/MDYY = '&STR';
END
TABLE FILE CAR
SUM MYDATE/YYMD
BY COUNTRY
END
Windows: WF 7.6.2: SQL Server 2008 R2 November 08, 2007, 04:00 PM
Jason K.I wonder why all the webfocus fuctions are so complicated.
It took me 5 minutes to figure out how to use trim. I've never seen a trim function, in any language, with as many parameters.
Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
November 08, 2007, 04:09 PM
Francis MarianiI agree. I don't know why the length of the string to be manipulated needs to be passed - the function should be able to figure that out, that's how it's done in almost all the other languages I've worked with.
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
November 08, 2007, 04:10 PM
PrarieKeeps it interesting.
| In Focus since 1993. WebFOCUS 7.7.03 Win 2003 |
November 08, 2007, 04:18 PM
Jason K.tom flynn, is that fancy speak for don't talk smack?
Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
November 08, 2007, 11:07 PM
TexasStingrayWell it looks like another runaway thread. I just do not understand, if someone ask for help and someone suggest a soluation and it works even thought it can be done differently without any performance gain. Then way does everyone have to try and show up some else. Maybe it is just to get there karma increased I don't know, but I got another point.
Scott
November 09, 2007, 06:38 AM
Tony ANever mind, it'll soon be Miller time again ...... Eh Prarie?
November 09, 2007, 08:51 AM
PrarieYep......
| In Focus since 1993. WebFOCUS 7.7.03 Win 2003 |