Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Convert Alphanumeric to 12-hour time

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Convert Alphanumeric to 12-hour time
 Login/Join
 
Member
posted
How would one go about converting a 4-byte alphanumeric field to a 12-hour time? Something along these line: 1600 -> 04:00 pm

Thanks!

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


Bob Neubauer
bob@databuilders.com
 
Posts: 10 | Registered: December 03, 2004Report This Post
Expert
posted Hide Post
I think you could use HINPUT to do this.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
TABLE FILE CAR
PRINT COUNTRY
COMPUTE ATIM/A4 = '1600' ;
COMPUTE TIME/HHIA = HINPUT(12,'00000000' | ATIM,8,'HHI') ;
END
 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Platinum Member
posted Hide Post
Write yourself a little function that you can call from an "include" whenever you want to convert the time. I wrote this one that I use all the time:

  
DEFINE FUNCTION TIMEAMPM(TIMEIN/A6)
-* get the time in a left-padded 6 character string and return character string in
-* the form hh:mm am/pm.  e.g.  Pass '000630' and return '6:30 am'.

-* TIMEIN = string field to parse in '00HHMM' military time format. 

-* get the hour and minutes as a string
HRTEMP/A2 = EDIT(TIMEIN, '$$99');
MINUTE/A2 = EDIT(TIMEIN, '$$$$99');
-* convert the hour into an integer so you can do some math and comparisons
HRTEMP1/I2 = ATODBL(HRTEMP, '02', 'I2');

-* if hr > 12 then (hr - 1) else hr
HOUR/A2 = IF HRTEMP1 GT 12 THEN FPRINT(HRTEMP1 - 12, 'I2', 'A2') ELSE HRTEMP;
-* if hr > 11 then 'pm' else 'am'
AMPM/A2 = IF HRTEMP1 GT 11 THEN 'PM' ELSE 'AM';

-* formats into hh:mm pm/am.  Note this is NOT in military time
TIMEAMPM/A8 = HOUR | ':' | MINUTE | ' ' | AMPM;

END
-RUN



You can tweak it for a 4 character input variable and adding a leading zero to the output if you desire.

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Platinum Member
posted Hide Post
Holy Moly Waz!!!! Eeker

You smoked me! Although I prefer to do things the hard way I will be looking closely at your solution. Good One


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Expert
posted Hide Post
Ah the forgotten date-time functions....
Cool


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Member
posted Hide Post
Wow! Thank you Norb and Waz...I really appreciate the help.


Bob Neubauer
bob@databuilders.com
 
Posts: 10 | Registered: December 03, 2004Report This Post
Expert
posted Hide Post
And don't forget...

Read
The
Functions
Manual

Always a great place to peruse.


Eek Eeker

I need to get a life.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Platinum Member
posted Hide Post
I've seen that acronym before but not defined in this way. Cool

Perhaps the excessive heat down under is starting to take it's toll and you can't recall the correct definition of RTFM. O.k I'll just STFU. Music


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
 
Posts: 242 | Location: Minneapolis | Registered: February 16, 2006Report This Post
Expert
posted Hide Post
Sweating


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Convert Alphanumeric to 12-hour time

Copyright © 1996-2020 Information Builders