CREATE procedure St_Proc_GetUserReportforCurrentDayTask
@userID int
as
Begin
set NoCount on;
DECLARE @TODAY DATE
SET @TODAY = CONVERT(VARCHAR(10), GETDATE(), 111)
select CONVERT(VARCHAR,production.CalendarDate,101) + RIGHT (CONVERT(VARCHAR,production.CalendarDate , 100 ) ,7) as Date,
RegionAndProjectInfo.RegionProjectName as Region ,
County.CountyName as County,
WorkType.WorkTypeName as WorkType,
Task.TaskName as Task,
Production.VolumeProcessed as 'Volumes Processed',
Production.TimeSpent as 'Duration'
from Production
inner join RegionAndProjectInfo
on
RegionAndProjectInfo.RegionProjectID=Production.RegionProjectID
inner join County
on
County.CountyID=Production.CountyID
inner join WorkType
on
WorkType.WorkTypeID=Production.WorkTypeID
inner join Task
on
Task.TaskID=Production.TaskID
where Production.UserID=@userID and CalendarDate >= @TODAY
End
From the above Stored Procedure i am filling a Dataset.After that i am binding this Dataset to a grid view.
In the dataset ,the Column Duration contains Data in HH:MM Format(example-01:00,12:45,02:59 etc).Is there a way that i can get the total of Duration in HH:MM format from the dataset itself.I dont want to query again from the Database to get the Sum of the Duration.
If you’re using at least SQL-Server 2008, you should use
Timedatatype to represent a .NETTimeSpan.To get it to work with a varchar-column, i would use
Linq-To-DataSet, for example:But that is only a workaround, actually you should really avoid to store a timespan in a varchar column, use varchar only for text and nothing else.
In SQL-Server 2005 (or other dbms) you could also use two columns, one for the start
DateTimeand one for the endDateTime.