textformat TimeSpan (and totals of a TimeSpan)

Stimulsoft Reports.NET discussion
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

textformat TimeSpan (and totals of a TimeSpan)

Post by jay@bplogix.com »

I am still unable to format a TimeSpan object in reports (Reports.Web). Is this now possible? What do I set the format string to if I want to see days and hours of a TimeSpan?

Thanks
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

textformat TimeSpan (and totals of a TimeSpan)

Post by Jan »

Hello Jay,
I am still unable to format a TimeSpan object in reports (Reports.Web).


Sorry I can't reproduce this problem. I try to format TimeSpan value with help of TextFormat function and it work fine. Can you provide expression which you use?
What do I set the format string to if I want to see days and hours of a TimeSpan?
For example:

Code: Select all

{MyTimeSpanValue.Days}

{MyTimeSpanValue.Hours}
Thank you.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

textformat TimeSpan (and totals of a TimeSpan)

Post by jay@bplogix.com »

Basically I want to use the Text Format to display a TimeSpan as Days:Hours:Minutes
I know I can do this "long hand" using {ts.Days}:{ts.Hours}:{ts.Minutes}
BUT how do I use a format string for the days? dd:HH:mm almost works ... but the dd always returns todays day number instead of the actual days in the timespan object.

ALSO ... the Custom format does not seem to work at all. If any value (for a TimeSpan object) is used in the Format Mask field, it behaves as if there were NO format string. The TimeSpan object only seems to look at the Format if you use a built-in format string (in the Date or Time groups).

To reproduce this, simply place this text control on a Report Header
{DateDiff(new DateTime(2011, 1, 1, 12, 44, 0), new DateTime(2011, 1, 7, 7, 0, 0))}
Then format it with a "custom format" of HH:mm ... notice that it does not listen.
Then choose a built-in Time format of HH:mm ... notice is does work.
Then choose a built-in Time format of dd:HH:mm (you may have to edit en.xml to add this format since custom format does not work) ... notice that the dd is always todays day number, not the days of the TimeSpan object.

Thansk!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

textformat TimeSpan (and totals of a TimeSpan)

Post by Alex K. »

Hello,

Please send us sample report which reproduces the issue for analysis.

Thank you.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

textformat TimeSpan (and totals of a TimeSpan)

Post by jay@bplogix.com »

Attached is the ZIP of the MRT. Basically I am trying to use ANY format string for a TimeSpan object. Right now, NO custom format strings work.
Attachments
1025.report.zip
(2.31 KiB) Downloaded 397 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

textformat TimeSpan (and totals of a TimeSpan)

Post by Alex K. »

Hello,

Support for formatting TimeSpan values was added in the .NET Framework version 4. However, the ToString() method overload remains culture-insensitive. Its behavior remains unchanged from previous versions of the .NET Framework.
For example, you can use the following formating:

Code: Select all

TimeSpanValue.ToString("%d")
TimeSpanValue.ToString("%d\:hh")
TimeSpanValue.ToString("%d\:hh\:mm")
TimeSpanValue.ToString("%d\:hh\:mm\.ss")
...
Thank you.
Attachments
1033.Report.mrt
(5.84 KiB) Downloaded 586 times
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

textformat TimeSpan (and totals of a TimeSpan)

Post by jay@bplogix.com »

How will this work on charts? I have input data that looks like this:
Region TimeSpan
A 1:10:34
B 2:40:24

The TimeSpan column is of type TimeSpan ... I want the chart to show a bar chart (2 bars ... A and B) of total hours in the timespan. I have attached an MRT that shows this. For the simple example I am using "List of Values" to point to 2 TimeSpan objects calculated from a formula. In my actual reports, the TimeSpan object is a column in a DataSource and I use "Value Data Column" to point to the column.

How do I format the TimeSpan in the cahrt to show total hours (or total days, or total minutes)? I cannot add a ToString to this, and the "Value Data Column" does not seem to allow me to add .TotalDays

Thanks
Attachments
1034.Report.mrt
(35.87 KiB) Downloaded 466 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

textformat TimeSpan (and totals of a TimeSpan)

Post by Alex K. »

Hello,

Sorry, but on the current moment, it is not possible to use the TimeSpan type by the calculated axis of a chart.
We have added your request to our to-do list, but I cannot say when it will be available.

Thank you.
Post Reply