Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a column with date-time and i want to add then display all the time from the start till the end as one record:

For example:
SQL
DelayTime:
1900-01-01 02:30:50.000
1900-01-01 03:20:10.000
1900-01-01 02:40:00.000
1900-01-01 00:10:00.000
1900-01-01 03:00:00.000
1900-01-01 06:20:00.000
1900-01-01 05:00:00.000
1900-01-01 01:00:00.000
1900-01-01 01:59:20.000
1900-01-01 00:04:00.000
1900-01-01 00:60:00.000
1900-01-01 00:30:00.000
1900-01-01 08:00:00.000
1900-01-01 09:30:00.000
1900-01-01 10:00:00.000
1900-01-01 03:35:00.000

Then Display as:

DelayTime:
The total time of Delaye
00:00:00
Only,Is it possible?
Posted
Updated 24-Apr-13 2:17am
v5
Comments
ZurdoDev 24-Apr-13 7:59am    
You want all those records to show as 00:00:00? Or, are you wanting to add up the times? Please be more clear.
gvprabu 24-Apr-13 7:59am    
see u need to find the delay time or... what is ur expected Output. Question is not clear. give some more explaination.
Puseletso Michelle 24-Apr-13 7:59am    
To show as 00:00:00
[no name] 24-Apr-13 8:00am    
Yes it is possible.
gvprabu 24-Apr-13 8:01am    
Give some actual Data with proper Date and Time and Sample Output also.

You can't use SUM on a DateTime and varchar column.

If your final goal is to get sum of all datadiff records in hh:mm:ss then stored the difference in minutes as:-

SQL
SELECT DATEDIFF(second,CAST('02:32:00' AS DATETIME)
, CAST('03:40:00' AS DATETIME))/60.0 AS MIN_DIFF;


Then to do sum of all minutes in hh:mm:ss then use:-

SELECT CONVERT(CHAR(8), DATEADD(Minute,convert(int, 68), '00:00:00'), 108)
 
Share this answer
 
Comments
gvprabu 24-Apr-13 8:59am    
First of all what is his actual requirement also we don't know.. :-)
Puseletso Michelle 24-Apr-13 9:33am    
@Trushnak Thanks Excatly what am looking for :-)
TrushnaK 24-Apr-13 10:12am    
Most Welcome...
TrushnaK 24-Apr-13 10:13am    
@gvprabhu read the conversion above between Sudhakar Shinde and Puseletso Michelle you clear about problem..
select 'DelayTime: The total time of Delaye 00:00:00'
 
Share this answer
 

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