Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.
-
Paul Aspinall #1
Summing time......
Hi
I have a field which is a Date/Time field....
It actually only makes use of the Time portion, and this holds a duration of
an activity....
However, I want to have a query which returns the total duration of all the
times in the records.
Is there an easy way, to SUM date/time fields (or just the time elements),
to give the total duration of all the records??
Thanks
Paul
Paul Aspinall Guest
-
summing data based on football seasons
Hi, I have 3 tables season, fixture and scorers. season is defined as: seasonID int(11) name varchar(20) with data like: -
Summing a repeated table...
Hi, Rob, I applied your extension to my application and it's great. Thank you! By the way, how can I format the "RR Totaliser Display"? I want it to... -
Summing Variable in CF 4.0
Hi Folks OK - I know I'm still using an old version of CF but I'm hoping someone can help me. Is there anyway to sum dyanmic variables in a... -
Summing a column and displaying in the footer
I would like to sum a column in my dataset and have it displayed at the bottom of the datagrid in the footer. How do I do that? -
Summing three levels in ASP
Hi I have three levels of cost items, like the following: TOP_LEVEL SECOND_LEVEL cost_item1 cost_item2 etc... TOP_LEVEL2 -
Nigel Rivett #2
Re: Summing time......
select sum(dtefld)
a datetime is just a decimal number with the integer part the date and
the decimal part the time. As you are just using the time the integer
part will be 0 (19000101) and you can just sum the fields to give a
total time.
Nigel Rivett (SQL Server MVP)
[url]www.nigelrivett.net[/url]
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Nigel Rivett Guest
-
Nigel Rivett #3
Re: Summing time......
select sum(dtefld)
a datetime is just a decimal number with the integer part the date and
the decimal part the time. As you are just using the time the integer
part will be 0 (19000101) and you can just sum the fields to give a
total time.
except that sum will not take a datetime so you can
select convert(datetime,sum(convert(decimal(18,5),dtefld) ))
But I suspect that this will lose some precision.
But maybe better to take advantage of the factr that a date is 2 4 byte
integer values - the second being the time so
select
convert(datetime,convert(binary(8),sum(convert(int ,convert(binary(4),
dtefld))))) from #a
Nigel Rivett (SQL Server MVP)
[url]www.nigelrivett.net[/url]
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Nigel Rivett Guest



Reply With Quote

