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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17179 |

    We have data that needs to include a time interval or duration.  Using PostgreSQL, we can use the Interval data type, but I don’t see that supported by the Xceed .Net Grid.  If we stored the data as integers (seconds), is there an easy way to format it correctly in h:mm:ss format?

    Imported from legacy forums. Posted by Mark (had 1273 views)

    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)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.