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

Time Format Question

Status
Not open for further replies.

metalteck

MIS
May 10, 2006
54
US
I am currently using Crystal 10 and added a field that represents time. Only problem is that its formatted as a number field instead of a time field. How can I convert this over.

Now Want to have
Ex.
608 6:38:00 AM
1334 1:34:00 PM
1218 2:34:00 PM
2241 10:41:00 PM

Thank you
 
I don't understand the formula used:

608 6:38:00 AM shouldn't it be 6:08
1334 1:34:00 PM
1218 2:34:00 PM shouldn't it be 12:18
2241 10:41:00 PM

Anyway, try a formula of:

stringvar MyTime := totext({table.timefield},0,"");
if len(MyTime) = 4 then
time(val(left(MyTime,2)), val(mid(MyTime,3)),0)
else
time(val(left(MyTime,1)), val(mid(MyTime,2)),0)

-k
 
I'm sorry, you are right. Those were typo's.

One last question, if the field only has one digit, how would I get it represent in time field, in addition to the formula you gave me?

Ex. Actually
6 12:06 am
12 12:10 am
45 12:45 am

Thank you
 
Try:

stringvar MyTime := totext({table.field},0,"");
if len(MyTime) = 4 then
time(val(left(MyTime,2)), val(mid(MyTime,3)),0)
else if len(MyTime) = 3 THEN
time(val(left(MyTime,1)), val(mid(MyTime,2)),0)
else if len(MyTime) <= 2 then
time(0, val(MyTime),0)

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top