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

currentTime problem

Status
Not open for further replies.

darwin101

Programmer
Mar 7, 2001
156
US
can anyone tell me what im doing wrong? i need to subtract a start time from the current time. the start time formula works but i get an error on the @stop time one.
// Current system time
CurrentDateTime

// @Start Time
numberVar hours;
numbervar minutes;
numberVar seconds;

If Not IsNull( {Job History.sdatetime} ) then
(
hours := toNumber({Job History.sdatetime}[12 to 13] ) * 3600 ;
minutes := toNumber({Job History.sdatetime} [15 to 16 ] ) * 60 ;
seconds := toNumber({Job History.sdatetime}[18 to 19 ] ) ;
hours + minutes + seconds
)
Else 0 ;

// @Stop Time
numberVar hours;
numbervar minutes;
numberVar seconds;

If Not IsNull ({@CurrentTime} ) then
(
hours := toNumber({@CurrentTime}[ 16 to 17 ] ) * 3600 ;
minutes:= toNumber({@CurrentTime}[ 19 to 20 ] ) * 60 ;
seconds := toNumber({@CurrentTime}[ 22 to 23 ] ) ;
hours + minutes + seconds
)
Else 0 ; The error message is "A string or an array of values is required here"

Thanks for your advice / help
 
The reason that you are getting this error is because the function CurrentDateTime returns a DateTime value. You can either modify your @CurrentTime formula to:

ToText(CurrentDateTime)

or you can modify your @StopTime formula:

// @Stop Time
numberVar hours;
numbervar minutes;
numberVar seconds;

If Not IsNull ({@CurrentTime} ) then
(
hours := toNumber(totext({@CurrentTime})[ 16 to 17 ] ) * 3600 ;
minutes:= toNumber(totext({@CurrentTime})[ 19 to 20 ] ) * 60 ;
seconds := toNumber(totext({@CurrentTime})[ 22 to 23 ] ) ;
hours + minutes + seconds
)
Else 0 ;

Obviously, its easier to modify the @CurrentTime formula
 
Thanks Rhinok! I ended up having to modify both of them to get it to work.. then I fould a logic error elsewhere.. OY
Thanks for your help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top