How to calculate in databand ?
mohanaraj
600001
Hello,
I want display the data by after some calculation in the databand.
In the databand i give [SecondsToHHmmss([dtOrgsummary.TI/C])] for the text object, while run the report it throw an error as Specified cast is not valid.
in this [dtOrgsummary.TI/C]---- data source field which this in the Int32 datatype.
and the function SecondsToHHmmss as follows
private string SecondsToHHmmss(int seconds)
{
int hours = seconds / 3600;
seconds = seconds - (hours * 3600);
int minutes = seconds / 60;
seconds = seconds - (minutes * 60);
return String.Format("{0:00}:{1:00}:{2:00}", hours, minutes, seconds);
}
where the function also accept the int as parameter. my data field also in Integer.
i can't get, where i was wrong.
I want display the data by after some calculation in the databand.
In the databand i give [SecondsToHHmmss([dtOrgsummary.TI/C])] for the text object, while run the report it throw an error as Specified cast is not valid.
in this [dtOrgsummary.TI/C]---- data source field which this in the Int32 datatype.
and the function SecondsToHHmmss as follows
private string SecondsToHHmmss(int seconds)
{
int hours = seconds / 3600;
seconds = seconds - (hours * 3600);
int minutes = seconds / 60;
seconds = seconds - (minutes * 60);
return String.Format("{0:00}:{1:00}:{2:00}", hours, minutes, seconds);
}
where the function also accept the int as parameter. my data field also in Integer.
i can't get, where i was wrong.
Comments
The dtOrgsummary.I/C column has decimal data type (in .xml data file). In a report, the DataType property of the column is set to Int32 which is not correct. You should set it to Decimal and use the following form:
[SecondsToHHmmss(ToInt32([dtOrgsummary.I/C]))]