Skip to Content
0

How to convert AS400 time to HH:MM

Oct 30, 2017 at 09:10 PM

37

avatar image
Former Member

Hi there,

So I am trying to figure out a formula to convert my times to HH:MM.

So 095003 would show as 9:50

145344 would should as 14:53

If the value is 0, it should show as N/A

I've spent more time than i'd like to admit trying to figure this out so I could use some help.

Thanks!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Abhilash Kumar
Oct 31, 2017 at 03:44 PM
1

Hi Kevin,

Is the time field's datatype number?

If yes, change the code to:

stringvar s := Right('000000'&totext({time field},'#'),6); //replace the {time field} with the correct database field
if s = '000000' then 'N/A'
Else if istime(picture(s,'xx:xx:xx')) then
totext(time(picture(s,'xx:xx:xx')), 'HH:mm')

-Abhilash

Share
10 |10000 characters needed characters left characters exceeded
Abhilash Kumar
Oct 31, 2017 at 09:54 AM
0

Hi Kevin,

Create a formula using this code:

stringvar s := {time field}; //replace this field with the correct database field
if s = '0' then 'N/A'
Else if istime(picture(s,'xx:xx:xx')) then
totext(time(picture(s,'xx:xx:xx')), 'HH:mm')

-Abhilash

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hey Abhilash, it gives me an error and highlights my field: "A string is required here"

0
Former Member

Thank you Abhilash, you are a life saver. The field is now displaying correctly for me.

0