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 formula Issue

Status
Not open for further replies.

bpvsc

MIS
Apr 30, 2002
18
US
I am in urgent need of assistance. I have a formula in Crystal that will convert a numeric field to a time field. The problem is if the numeric field is less than 1:00 AM I get an error message "String Length is Less than 0 or not an integer. The formula is below: Any help would be greatly appreciated:
Local StringVar strTime;
Local NumberVar numHr;
Local NumberVar numMin;
Local NumberVar numSec;
Local TimeVar tTime;
Local NumberVar numFldLen;

If Not(IsNull({AMAPPN00.AMLETI}))Then
(
// eliminate possible number formatting issues
strTime := Trim(Replace(Replace(Replace(ToText({AMAPPN00.AMLETI},0),":",""),",",""),".",""));

// breakout time components - hour component can be 1 or 2 digits
numFldLen := Length(strTime);
numHr := ToNumber(Left(strTime, numFldLen -4));
numMin := ToNumber(Mid(strTime, numFldLen -3, 2));
numSec := ToNumber(Right(strTime, 2));

// convert to time data type
tTime := Time(numHr,numMin,numSec)

)

Else
tTime := Time(0,0,0);

tTime
 
Your formula
<< numHr := ToNumber(Left(strTime, numFldLen -4)) >>
will fail if numFldLen is less than 4. Is this possible?
What does strTime look like when the database numeric field is less than 1:00 AM?
 
If the strTime is less than 1:00AM it shows 23(for 23 seconds after midnight . Also is could be blank if the process has not been completed yet but I expect the isnull takes care of that.

Thanks for the response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top