Click here to Skip to main content
15,900,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am converting my data from my datatable to pdf but the thing is i want show the total duration in footer in pdf file . time in HH:mm:ss format in my last column named DialledDuration.
Posted
Comments
George Jonsson 1-Dec-15 2:05am    
Can you explain a little bit more?
Is how to format the time string that is the problem?

1 solution

C#
var sum = (TimeSpan)dt.Compute("Sum(DialledDuration)", "");
lblTotal.Text = String.Format("{0} Days {1} Hours {2} Minutes {3} Seconds",sum.Days,sum.Hours,sum.Minutes,sum.Seconds);
 
Share this answer
 
Comments
venkataramana k 1-Dec-15 7:28am    
when i code like this it will shows error
"Invalid usage of aggregate function Sum() and Type: String."
Jawad Ahmed Tanoli 1-Dec-15 7:34am    
you must define your datatable with datatype like this

DataTable workTable = new DataTable("Customers");

DataColumn workCol = workTable.Columns.Add("CustID", typeof(Int32));
workCol.AllowDBNull = false;
workCol.Unique = true;

workTable.Columns.Add("CustLName", typeof(String));
workTable.Columns.Add("CustFName", typeof(String));
workTable.Columns.Add("Purchases", typeof(Double));
Jawad Ahmed Tanoli 1-Dec-15 7:30am    
it means your DialledDuration is string datatype how many columns in your datatable

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