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

Time Spent In Queue

Status
Not open for further replies.

hjay

MIS
May 1, 2003
1
US
I'm trying to find the duration an item has spent in queue as of the current date. I tried to piece some example formulas together but no luck. Any suggestions on what's wrong with this formula?


Numbervar Dys:=Date(currentdatetime)-Date({sps_GetOpenWork_test;1.DateReceived});
Numbervar Secs:=(Time(currentdatetime)-Time(0,0,0))-(Time({sps_GetOpenWork_test;1.DateReceived})-Time(0,0,0));


NumberVar TotalSec := Dys*86400+Secs;
NumberVar Days := Truncate (TotalSec / 86400);
NumberVar Hours := Truncate (Remainder ( TotalSec,86400) / 3600);
NumberVar Minutes := Truncate (Remainder ( TotalSec,3600) / 60);
NumberVar Seconds := Remainder ( TotalSec , 60);


Totext ( Days, '00', 0,'') + ':'+
Totext ( Hours, '00', 0,'') + ':'+
Totext ( Minutes,'00', 0,'') + ':'+
Totext ( Seconds,'00', 0,'')
 
Preface the formula with "WhilePrintingRecords"

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
dgilsdorf@trianglepartners.com
 
What version are you using?

If you are using v8 and up you can use the datediff to calculate your seconds:

datetimevar dt1:={sps_GetOpenWork_test;1.DateReceived};
datetimevar cd1:=currentdatetime;

NumberVar TotalSec := datediff("s",dt1,cd1);

the rest of your formula



Mike
 
I think you can use:

( CurrentDateTime - {Your.DateTimeField} ) * 86400

to convert elapsed time into seconds.
Then you can run that value through the duration format.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top