July 06, 2007, 04:00 PM
JOEDate Format
Hi,
Can a date formatted for example (2007070400) be converted to 2007/07/04? The two zeros at the end need to be parsed out. I can't find examples on this. Thanks for any help.
Joe
WebFocus 7.7.02 WinXP
July 06, 2007, 04:40 PM
FrankDutchJoe
yes it can....
There are many ways depending on the original format.
If it is a string (A10)
NEWYMD/A8YYMD=EDIT(ORIGINAL,'99999999');
But it also depends on the way you want to use the result. If you want to calculated with it, you should convert it to a smartdate.
There is a very good money worth book (U$ 25) that explanes all the formulas.
|
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 |
July 06, 2007, 04:53 PM
Darin LeeI believe the "Using Functions" book is also available via download for registered users, but I have a printed copy (to read in my spare time. Also serves as a nice desk decoration. I keep it in a very "reachable" spot.)
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
July 06, 2007, 05:01 PM
FrankDutchDarin
the book I referred to is the "Almost 1001 ways to work with dates" and is not in digital format available.
|
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 |
July 06, 2007, 09:50 PM
JOEThanks,
Actually, the date field in question - event_partkey is originally formatted as I11. I tried NEWYMD/I8YYMD = EDIT(EVENT_PARTKEY,'99999999'); and received a format error. Should I redefine the metadata as A10 and not as an integer.
Thanks,
Joe
WebFocus 7.7.02 WinXP
July 07, 2007, 04:38 AM
FrankDutchJoe
do it in steps
NEWADATE/A11=EDIT(ORIGINAL); is converting from Integer to alpha.
NEWYMD/A10=EDIT(NEWADATE,'99/99/9999$$'); is masking the alpha string to the format you want, but keep in mind this is only a date looking string and not a real smart date.
|
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 |
July 10, 2007, 12:43 PM
jgelonaIf the orginal date is I11, to convert to smart date use the following in a DEFINE:
FMTDT/YYMD=DATECVT(ORIG_DT/1000,'I8YYMD','YYMD');
For example:
DEFINE FILE MACGYVER
ORIG_DT/I11=20071231000;
FMTDT/YYMD=DATECVT(ORIG_DT/1000,'I8YYMD','YYMD');
END
TABLE FILE MACGYVER
PRINT ORIG_DT FMTDT
WHERE COUNTER EQ 1
END
In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
July 13, 2007, 02:54 AM
PiipsterThis seems to work as well:
DEFINE FILE CAR
IDATE/I11 = 2007070400;
IDATE1/I8YYMD = IDATE/100;
IDATE_YYMD/YYMD = IDATE1;
END
TABLE FILE CAR
PRINT IDATE IDATE1 IDATE_YYMD
BY COUNTRY
END
ttfn, kp
Access to most releases from R52x, on multiple platforms.
July 20, 2007, 04:07 PM
JOEThanks for all your help. I finally got it to work. I did the following:
NEWADATE/A11=EDIT(EVENT_PARTKEY,'$99999999$$');
NEWYMD/A10=EDIT(NEWADATE,'9999/99/99');
Worked great!
WebFocus 7.7.02 WinXP
July 22, 2007, 05:41 AM
FrankDutchJoe
why do you have to mask the first character?
is there a space in the database field?
is it always there?
what I would do in this case to be sure it works always is first convert the A11-string to an integer.
NEWINT/I10=EDIT(NEWADATE);
then use the integer for the next step as suggested by Piipster.
|
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 |
July 22, 2007, 03:07 PM
JOEThat's what baffled me too. I did not see a space in the first character until I ran test data. I'll try your suggestion and let you know how it works.
Joe
WebFocus 7.7.02 WinXP