cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert AS400 time to HH:MM

0 Kudos

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!

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor

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

Answers (1)

Answers (1)

abhilash_kumar
Active Contributor
0 Kudos

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

0 Kudos

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

0 Kudos

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