Jump to content

Query


sandy1028

Recommended Posts

Hi,

 

These are the fields in the table.

timestamp

state    | varchar(1)    | YES  |    | NULL             

| cputime  | varchar(12)  | YES  |    | NULL               

| memused  | decimal(10,2) | YES  |    | NULL     

 

The values in fieldname state changes from R to C when the task is completed.

 

Please help me with a query how can we find the timetaken to change the state from R to C.

Link to comment
Share on other sites

Yes you can, store the time in a variable when the task has started and completed

 

<?php $timestart=date("H:i"); //  get the time
        /// do  your task here 
       $timecomplete=date("H:i");
      /// after that 
     deduct the time difference and save it 
    $timetaken = $timecomplete - $timestart;

?>

 

But how will the task occur, by pressing some buttons or what ???

Link to comment
Share on other sites

Hi,

 

the simplest way to do exactly what you've described is adding to your INSERTS/UPDATES information of start times when a record enters appropriate state, e.g. datetimeOfRState and datetimeOfCState. Then to obtain the taken time you just need to select a difference of these times. Times when a record enters given state may also be maintained using TRIGGERS.

 

If your description is incomplete you must notice that this way is only for one change from state R to C. When you are not sure if requirements will change safer way is to create special table that will store information of changing states.

 

Michal

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.