Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time formulas = HH:MM:SS

Status
Not open for further replies.

slimshades26

Technical User
May 10, 2002
61
0
0
US
CR8.5
Looking to put the AS400 numeric data field {F55ALLOC.S5TDAY} to standard 24 hour:

191832 = 19:18:32
249 = 00:02:49
22713 = 02:27:13

Among other tries the following formulas and undesired results:

ISTIME() formula gives me "true"
CTIME() formula gives me "0:00:00" for every record.
TIME() formula gives me "0:00:00" for every record.

Thanks for any response. ss26
 
Got it.

ctime(tonumber(left(right("000000"&totext({F55ALLOC.S5TDAY}),6),2)),
tonumber(mid(right("000000"&totext({F55ALLOC.S5TDAY}),6),3,2)),
tonumber(right(right("000000"&totext({F55ALLOC.S5TDAY}),6),2)))
ss26
 
well I might do it a bit differently

WhilePrintingRecords;
//this pads the left with zeros if less than 6 chars
stringVar temp := totext({F55ALLOC.S5TDAY},"000000")
stringVar result := "";

result := time(tonumber(temp[6 to 5]),tonumber(temp[4 to
3]),tonumber(temp[1 to 2]));

result;

Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top