Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi am using sqlserver 2005. i hv a table in which 5 columns are there Start_time, pause_time, continue_time, pause_duration, end_time and total_duration. when i clicked on pause_time and continue_time the time difference should be displayed in pause_duration column for that i hv written the code. the thing is when i clicked on pause_time and continue_time the differnce should be added to the previous result for that what i need to do?

pls help...
thankks in advance,
Posted
Comments
CHill60 23-Jan-13 4:53am    
What do you mean by "added to the previous result" ? Do you mean total_duration?
in C# total_duration += difference
in SQL Update [table] set total_duration = total_duration + difference where ...
brinda f5 23-Jan-13 5:07am    
1st time when i clicked on pause_time and continue_time the difference should be inserted in pause_duration column and 2nd time when i clicked on pause_time and continue_time the difference should be added to the previous value in pause_duration column.
brinda f5 23-Jan-13 5:24am    
no every thing should be inserted in 1 row itself

in C# pause_duration += difference
in SQL Update query set pause_duration = pause_duration + difference

and if you are storing in SQL the pause time and continue time in different rows then the pause duration will be the some for that unique id
 
Share this answer
 
First calculate the time difference and store it. Then when a new difference is calculated just add that to the previous value.

C#
//The first time it is null when initializing.
PauseDuration = null;

//Then every time for calculation
PauseDuration += ContinueTime - PauseTime;
 
Share this answer
 
Comments
brinda f5 23-Jan-13 23:20pm    
which datatypes i hv to take for pauseduration,continuetime and pausetime
shiny13 23-Jan-13 23:41pm    
Initialize the variables ContinueTime and PauseTime as DateTime. Everytime you subtract two DateTime variables the out is generated in TimeStamp, so you can initialize PauseDuration as Timestamp. A TimeStamp variable can be converted to string if you want to display it. By default it is in this format: "hh:mm:ss:nn" where hh is hour, mm is minute, ss is second and nn is nano second or microsecond (not exactly sure but could be either).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900