This is a migrated thread and some comments may be shown as answers.

DateTime as Group

3 Answers 218 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
y2kbowen
Top achievements
Rank 1
y2kbowen asked on 21 Jan 2008, 05:55 AM
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

Sort by
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.

I hope this information helps.

Kind regards,
Milen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kyle
Top achievements
Rank 1
answered on 21 Jul 2016, 08:02 PM
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.

Step-by-step instructions on how to add a group are provided in How to: Add groups to Report help article.


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
Tags
General Discussions
Asked by
y2kbowen
Top achievements
Rank 1
Answers by
Milen | Product Manager @DX
Telerik team
Kyle
Top achievements
Rank 1
Katia
Telerik team
Share this question
or