Displaying the TimeSpan in a report via script

The following is a further customization of the Labor grid’s Sample Schedulable Users Billing Hours with Grand Totals report to include displaying the difference in hours between the Service Stop Date & Time and Service Start Date & Time - such a field may be useful in checking that the actual hours worked are entered in the Billable Hours and No Charge Hours.

Download the report template [b]Sample Total Actual Hours Schedulable Users Billing Hours with Grand Totals[/b]report

I would suggest filtering the Labor grid by the specific user (User field) and the date you wish to report on (Service Start Date & Time using a custom filter selecting greater than a date, and less than a date such as identified in the forum topic http://forum.ayanova.com/Topic1430-100-1.aspx?Highlight=greater+than)

Example of a print preview of this report template

The field xrLabel21 script property OnBeforePrint uses the following script<P dir=ltr " ">private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
//this gets the object value of the Stop Date & Time
DateTime dt1 = Convert.ToDateTime(GetCurrentColumnValue(“LT_WorkorderItemLabor_Label_ServiceStopDate”));
//this gets the object value of the Start Date & Time
DateTime dt2 = Convert.ToDateTime(GetCurrentColumnValue(“LT_WorkorderItemLabor_Label_ServiceStartDate”));
//this subtracts the start date & time from the stop date & time
TimeSpan ts = dt1.Subtract(dt2);
//this displays the timespan in total hours (if you want to display in minutes, than change TotalHours to TotalMinutes
xrLabel21.Text = ts.TotalHours.ToString();