I am using a datetime as the control for a group. It seems that the group control does not use the formatted value of the value as the grouping criteria. So, how can I get a group to only group on the date part and not on the datetime part?
3 Answers, 1 is accepted
0
Milen | Product Manager @DX
Telerik team
answered on 21 Jan 2008, 01:31 PM
Hello y2kbowen,
I suppose the type of the column you want to use as group criteria is datetime. You can use a user defined function to truncate the time part of the datetime values.
Something like:
public static object TruncTime(object value)
{
if (value == null || value == DBNull.Value)
return null;
//if the cast throws exception, there is something wrong with the dataset
DateTime datetime = (DateTime)value;
return datetime.Date;
}
As a group condition use
= TruncTime(Fields.DateColumn)
where the DateColumn is the name of the column you are grouping on.
Why cant we just do something like Fields.DateTimeField.Date? Or Fields.DateTimeField.ToString("D")? I tried these and neither seems to work.
0
Katia
Telerik team
answered on 25 Jul 2016, 12:15 PM
Hello Kyle,
The post you are referring to is several years old.
The approaches you suggested work in later versions of the product. You can specify the grouping expression as = Fields.DateField. which will group the data by the date only ignoring the time value.
Another approach to format the DateTime values is with ToString(formatString) or Format() built-in function. Thus, test upgrading to the latest version and check if this produces the expected result.
In case, the issue persists please send us the problematic report definition in a support ticket so we can check the settings and provide you further suggestions.
Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items