Skip to Content
avatar image
Former Member

How to convert AS400 time to HH:MM

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!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 31, 2017 at 03:44 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 31, 2017 at 09:54 AM

    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

    Add comment
    10|10000 characters needed characters exceeded