Focal Point
converting 20071108 to a Date?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1921043652

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 Mariani
WebFOCUS 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 Mariani
Date-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
GinnyJakes
quote:
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 Mariani
You 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 Mariani
quote:
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
FrankDutch
Francis, 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 Mariani
Frank, 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
Gizmo
I 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 Mariani
Well, 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 Mariani
Ah 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
Gizmo
Ahhh, 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 Music



Windows: WF 7.6.2: SQL Server 2008 R2
November 08, 2007, 03:48 PM
Gizmo
Tom

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 Mariani
I 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
Prarie
Keeps it interesting. Wink


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
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.
Well 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. Big Grin




Scott

Never mind, it'll soon be Miller time again ...... Eh Prarie?
Yep......


In Focus since 1993. WebFOCUS 7.7.03 Win 2003