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

Time converstion-remove ":" from field

Status
Not open for further replies.

BROWNIE56

Programmer
Dec 28, 2000
31
US
I have a method I use to convert our time from a database from military time to "civilian time."

I just ran across one field in a table that has the time stored as:

12:15 instead of 1215 (like the rest of our tables with time).

How can I remove the ":" to make the following formula work?

WhilePrintingRecords ();
StringVar szTime;
if({CASE_INFORMATION.case_toi} = " " or IsNull ({CASE_INFORMATION.case_toi})) or Left(ToText({CASE_INFORMATION.case_toi}) ,2) = "0"
then
szTime:=" "
else
If(ToNumber ({CASE_INFORMATION.case_toi})) >= 1200
then If(ToNumber ({CASE_INFORMATION.case_toi}) >= 1259 and ToNumber ({CASE_INFORMATION.case_toi}) < 2200)
then szTime:=Picture(ToText ((ToNumber ({CASE_INFORMATION.case_toi}) -1200),0,&quot;&quot;,&quot;&quot;) ,&quot;X:XX pm&quot;)
else If(ToNumber ({CASE_INFORMATION.case_toi}) >= 2200)
then szTime:=Picture(ToText ((ToNumber ({CASE_INFORMATION.case_toi}) -1200),0,&quot;&quot;,&quot;&quot;) ,&quot;XX:XX pm&quot;)
else szTime:= Picture({CASE_INFORMATION.case_toi}, &quot;XX:XX pm&quot;)
else szTime:= Picture({CASE_INFORMATION.case_toi}, &quot;XX:XX am&quot;);

 

WhilePrintingRecords ();

StringVar szTime;
if({CASE_INFORMATION.case_toi} = &quot; &quot; or IsNull ({CASE_INFORMATION.case_toi})) or Left(ToText({CASE_INFORMATION.case_toi}) ,2) = &quot;0&quot;
then
szTime:=&quot; &quot;
else
StringVar MyTimeString:= ToText(Val({CASE_INFORMATION.case_toi}),0) + Right({CASE_INFORMATION.case_toi},2);
If(ToNumber (MyTimeString)) >= 1200
then If(ToNumber (MyTimeString) >= 1259 and ToNumber (MyTimeString) < 2200)
then szTime:=Picture(ToText ((ToNumber (MyTimeString) -1200),0,&quot;&quot;,&quot;&quot;) ,&quot;X:XX pm&quot;)
else If(ToNumber (MyTimeString) >= 2200)
then szTime:=Picture(ToText ((ToNumber (MyTimeString) -1200),0,&quot;&quot;,&quot;&quot;) ,&quot;XX:XX pm&quot;)
else szTime:= Picture(MyTimeString, &quot;XX:XX pm&quot;)
else szTime:= Picture(MyTimeString, &quot;XX:XX am&quot;);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top