Focal Point
Converting Alphanumeric Fields to Dates [SOLVED]

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

February 15, 2012, 02:05 PM
MCKELPA99
Converting Alphanumeric Fields to Dates [SOLVED]
There has been quite a bit of changes to how dates are handled. I need to know a simple way or function for converting an alpha field to a date field.

This message has been edited. Last edited by: MCKELPA99,


WebFOCUS 7.7.02
Unix
All Output
February 15, 2012, 02:58 PM
Waz
What is the format of the alpha dates ?


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!

February 15, 2012, 03:05 PM
njsden
Well, you could start by taking a look at my favourite DATECVT function and play with it.

As Waz indicates, the "format" in which your date string is represented plays an important role into how the conversion can be done.

TABLE FILE CAR
PRINT CAR NOPRINT
COMPUTE DATE_STR/A10 = '20120214';
COMPUTE DATE_DT/YYMD = DATECVT(DATE_STR, 'A8YYMD', 'YYMD');
WHERE RECORDLIMIT EQ 1
END




Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 15, 2012, 04:40 PM
MCKELPA99
The DATECVT function worked for me....thanks njsden. The format of the alpha date is A8 or A8MDYY (ex. '10/01/2009'). Actually, A8MDYY worked with the function.


WebFOCUS 7.7.02
Unix
All Output
February 15, 2012, 04:57 PM
Waz
The other way to do this is:
TABLE FILE CAR
PRINT CAR NOPRINT
COMPUTE STR_DATE/A8MDYY = EDIT('10/01/2009','99$99$9999') ;
COMPUTE MY_DATE/MDYY  = STR_DATE ;
WHERE RECORDLIMIT EQ 1
END


The function is the simpler.


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!

February 15, 2012, 05:07 PM
njsden
quote:
The function is the simpler.


But you need to 2 fields ... Music



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 15, 2012, 05:17 PM
MCKELPA99
Thanks for this method as well. Consider this one resolved.


WebFOCUS 7.7.02
Unix
All Output
February 15, 2012, 05:24 PM
Waz
2 Steps..........2 Fields

6 of one, half dozen of the other...



MCKELPA99, you can update your first post in the this thread, and add [SOLVED] to the title.


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!

February 15, 2012, 06:30 PM
MCKELPA99
quote:
[SOLVED]



WebFOCUS 7.7.02
Unix
All Output
February 15, 2012, 06:31 PM
MCKELPA99
[SOLVED]


WebFOCUS 7.7.02
Unix
All Output
February 15, 2012, 06:48 PM
Waz
You can edit your first post in the thread by clicking on the folder icon with the erasor, on the right hand sode of the post


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!

February 16, 2012, 10:37 AM
MCKELPA99
Thanks....


WebFOCUS 7.7.02
Unix
All Output