Home Forums WinForms controls Xceed Grid for WinForms How Can I Represent Time Intervals in Grid? Reply To: How Can I Represent Time Intervals in Grid?

User (Old forums)
Member
Post count: 23064

This is a standard .NET method, not relevant from any Xceed controls or components.

String

.Format(“Time: {0:hh:mm:ss}”, new TimeSpan(0,0,seconds));   //  could be {0:HH:mm:ss} depending on your local settings

would convert the interval into a “23:59:59” string format.  Be aware that if there is more the interval is larger than 23h 59m 59s, “(numberOfDays).” will be leading the time.  I.e.  76 hours would return “3.04:00:00”

To convert this back into seconds:

long seconds = TimeSpan

.Parse(dataRow.Cells[“ElapsedTimeColumn”].Value as string).TotalSeconds;

Imported from legacy forums. Posted by Ghislain (had 1168 views)