DateTime as Group

4 posts, 0 answers
  1. y2kbowen
    y2kbowen avatar
    1 posts
    Member since:
    Jul 2007

    Posted 20 Jan 2008 Link to this post

    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?

  2. Milen
    Milen avatar
    181 posts

    Posted 21 Jan 2008 Link to this post

    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,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Kyle
    Kyle avatar
    15 posts
    Member since:
    Mar 2016

    Posted 21 Jul 2016 in reply to Milen Link to this post

    Why cant we just do something like Fields.DateTimeField.Date? Or Fields.DateTimeField.ToString("D")? I tried these and neither seems to work.
  4. Katia
    Katia avatar
    760 posts

    Posted 25 Jul 2016 Link to this post

    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.Date 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.

    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
Back to Top