Focal Point
[SOLVED] Date Conversion

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

July 13, 2015, 04:20 PM
texgator
[SOLVED] Date Conversion
I have the ORDATE stored in P8.0 and ORDTME stored in P6.0 format. I need to convert it to DATETIME format MM/DD/YYYY 24HH:MI:SS. I tried the following but it outputs milliseconds as well - Would appreciate if someone could help with this. Thanks.


DATE1/A8 = EDIT(ORDATE, '$99999999');
TIME1/A6 = EDIT(ORDTME, '$999999');
ALPHA_DATE_TIME/A15 = DATE1 | TIME1;
ORDER_DATETIME/HMDYYS = HINPUT(14, ALPHA_DATE_TIME, 8, 'HMDYYS');

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 7.6.10
Windows
all output (Excel, HTML, PDF)
July 13, 2015, 04:57 PM
Francis Mariani
Interestingly, I don't get the milliseconds with HMDYYS, and do get them with HMDYYs. Example code:
DEFINE FILE CAR
DATE1/A8 = '&YYMD';
TIME1/A6 = EDIT('&TOD','99$99$99');

ALPHA_DATE_TIME/A15 = DATE1 | TIME1;
ORDER_DATETIME1/HMDYYS = HINPUT(14, ALPHA_DATE_TIME, 8, 'HMDYYS');
ORDER_DATETIME2/HMDYYs = HINPUT(14, ALPHA_DATE_TIME, 8, 'HMDYYs');
END

TABLE FILE CAR
PRINT
ORDER_DATETIME1
ORDER_DATETIME2
BY COUNTRY
WHERE RECORDLIMIT EQ 1
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
July 13, 2015, 05:43 PM
texgator
Thanks Francis. I do not get the milliseconds in the display but if I do APP HOLD and hold it as a table (which I need to do), then there are two problems
1. It is stored as 20150101082924000 when I need it to be stored as 01012015... i.e. MDYY
2. There are those three 0s at the end for milliseconds.

I am doing APP HOLD and then ON TABLE HOLD FORMAT DFIX DELIMITER |

Any solutions?


WebFOCUS 7.6.10
Windows
all output (Excel, HTML, PDF)
July 14, 2015, 03:51 AM
Tony A
One way would be using FPRINT to convert to alpha and then use an EDIT mask to retain only those characters in which you are interested.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
July 14, 2015, 09:44 AM
Francis Mariani
texgator, it would be nice if the whole problem was described in the original post. As Tony mentions, you can use FPRINT and EDIT:

SET HOLDLIST=PRINTONLY

DEFINE FILE CAR
DATE1/A8 = '&YYMD';
TIME1/A6 = EDIT('&TOD','99$99$99');

ALPHA_DATE_TIME/A15 = DATE1 | TIME1;
ORDER_DATETIME1/HMDYYS = HINPUT(14, ALPHA_DATE_TIME, 8, 'HMDYYS');
ORDER_DATETIME2/HMDYYs = HINPUT(14, ALPHA_DATE_TIME, 8, 'HMDYYS');
END

TABLE FILE CAR
PRINT
-*ORDER_DATETIME1
-*ORDER_DATETIME2
COMPUTE ORDER_DATETIME3TEMP/A19 = FPRINT(ORDER_DATETIME1, 'HYYMDS', 'A19'); NOPRINT
COMPUTE ORDER_DATETIME3/A14 = EDIT(ORDER_DATETIME3TEMP,'9999$99$99$99$99$99');
BY COUNTRY
WHERE RECORDLIMIT EQ 1
ON TABLE HOLD
END

?FF HOLD

TABLE FILE HOLD
PRINT *
END

This message has been edited. Last edited by: Francis Mariani,


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
July 17, 2015, 12:38 AM
texgator
Thanks much Francis and Tony for your help. The issue has been resolved.


WebFOCUS 7.6.10
Windows
all output (Excel, HTML, PDF)