Focal Point
[SOLVED]Converting a time from 24hr to 12 hour with AM and PM

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

October 13, 2016, 11:27 AM
Trudy
[SOLVED]Converting a time from 24hr to 12 hour with AM and PM
Is there a way to convert a time field that is an A4V field to a 12hr with AM and PM field?

Thanks Trudy

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


WF8
Windows
October 13, 2016, 11:52 AM
Tony A
quote:
an A4V field

As you are working with alpha values (not a time field), you will need to manipulate it yourself.

Simple conversion and equally simple maths to follow before converting back to an alpha suffixed with "am" or "pm" as necessary.

To my knowledge, there is no time format (think HHIS etc.) that has am or pm suffixes.

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 
October 13, 2016, 02:09 PM
Francis Mariani
Here's an example.

My assumption is that the alphanumeric column (A4V) contains two digits that represent hours and two digits that represent minutes. To convert this alphanumeric column to a date/time column, a date must be inserted - I use 9999/12/31 as the dummy date. 'HHIA' represents a date/time column (the first H), formatted to show hours (the second H), minutes (I) and AM/PM (A).

DEFINE FILE CAR
MY_TIME/A4V = 
     IF COUNTRY EQ 'ENGLAND' THEN '1010' 
ELSE IF COUNTRY EQ 'FRANCE' THEN '2123' 
ELSE IF COUNTRY EQ 'ITALY' THEN '0559' 
ELSE IF COUNTRY EQ 'JAPAN' THEN '2359' 
ELSE '1129';

TEMP_DATETIMEX/A14 = '99991231' | MY_TIME;

MY_TIME_F1/HHIA = HINPUT(14, TEMP_DATETIMEX, 8, 'HHIA');

MY_TIME_F2/HHIa = HINPUT(14, TEMP_DATETIMEX, 8, 'HHIa');

END

TABLE FILE CAR
PRINT 
MY_TIME
TEMP_DATETIMEX
MY_TIME_F1
MY_TIME_F2
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
October 13, 2016, 03:54 PM
Trudy
Thanks for the help. I used the example from Francis and applied it to my scenario. I was able to concatenated a start time with an end time using the following code.

BTEMP_DATE/A14='99991231'|J13.SSRMEET.SSRMEET_BEGIN_TIME;
BTime/HHIa=HINPUT(14, BTEMP_DATE, 8, 'HHIa');
ETEMP_DATE/A14='99991231'|J13.SSRMEET.SSRMEET_END_TIME;
ETime/HHIa=HINPUT(14, ETEMP_DATE, 8, 'HHIa');
FTime/A15=HCNVRT(BTime, '(HHIa)', 7, 'A7')|'-'|HCNVRT(ETime, '(HHIa)', 7, 'A7');  



WF8
Windows