-1

Maybe I'm confusing something but I can't figure out if there is a way to format a TimeSpan that has a value such as: 4.21:02:00 as 117 hours, 2 minutes (change full days to hours)

I have done it using CustomDrawCell and it works but seems to be overkill.

Moreover CustomDrawCell event occurs if Grid is displayed, but while I'd like to print that grid "that modifications ... on this event are ignored when you print or export Grid data."

how can I achieve this by:

[DisplayFormat(DataFormatString = "{0:HH} hours, {0:mm} minutes")]

Or perhaps another Custom Display format?

Paweł Swajdo
  • 391
  • 1
  • 13
  • 1
    A timestamp is a point in time. How would that be more than 24 hours?. I think you need to look at timespan, the formats are here: https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings. – Palle Due Feb 02 '21 at 17:08
  • Of course I've meant TimeSpan, thanks for pointing this out :) – Paweł Swajdo Feb 02 '21 at 17:13

1 Answers1

0

Reference this post: Format TimeSpan greater than 24 hour

Breakdown:

return string.Format("{0}hr {1}mn {2}sec",
                 (int) span.TotalHours,
                 span.Minutes,
                 span.Seconds);

Credit: User:https://stackoverflow.com/users/22656/jon-skeet

Or see answer on same post from User: https://stackoverflow.com/users/3120446/dx-over-dt

ttodorov
  • 32
  • 4