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

Format Text to Time

Status
Not open for further replies.

haneen97

Programmer
Dec 10, 2002
280
US
Hi Trying to format a 4 cahrachter text field to time. The code is bwlow:

Local StringVar AMPM := "";
Local StringVar HR := "";
Local NumberVar NHR := 0;

IF LEFT({ENCV_SCHEDULEBYRESOURCE.KEY_TIME},2) >= "12" THEN
AMPM := "PM"
ELSE AMPM := "AM";

NHR := tonumber(LEFT({ENCV_SCHEDULEBYRESOURCE.KEY_TIME},2));

IF NHR >= 13 THEN
NHR := NHR - 12;

HR := totext(truncate(NHR));
HR+":"+MID({ENCV_SCHEDULEBYRESOURCE.KEY_TIME},3,2)+" "+AMPM;


The problem is that the HR desplays as (9.00) for example; with two decimal digits.

How can we get rid of the (.00) from the HR field.

Thanks a lto.

Mo
 
Change HR := totext(truncate(NHR));

to

HR := totext(truncate(NHR),0);

The 0 indicates 0 decimal places.

 
Thank you Lady JAG,
That was the trick.

Mo

Mo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top