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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TIME SPECIAL FORMULA

Status
Not open for further replies.

rossallen

IS-IT--Management
Sep 19, 2003
8
AU
In SQL Database using Crystal V9 I am trying to show time field RT_TIME correctly which is stored in the database as a number field so that 150759 I want to show as 3:07:59 PM Which is the best formula to use
 
Try:

time(val(left(totext({table.RT_TIME},0,""),2)),val(mid(totext({table.RT_TIME},0,""),3,2)),val(mid(totext({table.RT_TIME},0,""),5,2)))

-LB
 
I think that you'll get in trouble with LB's formula with single digit AM hours, instead use:

if len(totext({table.field},0,"")) = 6 then
time(val(left(totext({table.RT_TIME},0,""),2)),val(mid(totext({table.RT_TIME},0,""),3,2)),val(mid(totext({table.RT_TIME},0,""),5,2)))
else
if len(totext({table.field},0,"")) = 5 then
time(val(left(totext({table.RT_TIME},0,""),1)),val(mid(totext({table.RT_TIME},0,""),2,2)),val(mid(totext({table.RT_TIME},0,""),4,2)))

-k
 
Thank you both synapsevampire and lbass for your replys, works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top