Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • gary 385 posts 915 karma points
    Feb 26, 2013 @ 19:34

    V6 GroupBy and DateTime Format

    Hi, need some help finishing this off, if possible.

    This is what I have, it groups under a date then by create date, both descending. This part is fine and returns as required.

    @{   var root = Model.Content.AncestorOrSelf();

       var top = root.Descendants("dailyspecials").OrderBy("Date desc").GroupBy("Date");


        @foreach (var groupDate in top)  

        { @groupDate.Key

            foreach (var item in groupDate.OrderBy("CreateDate desc"))
                 <li><a href="@item.Url()">@item.Up(1).GetPropertyValue("Restaurant")</a></li>
    The part that I am struggling to achieve is to convert the Object Date, into a string to give something "readable" that can be displayed. At the moment it returns 3/23/2013 12:00:00 AM. To achieve the GroupBy, I have had to use the static, but, would either would like to achieve dynamically, or convert the returned object, Date to a DateTime string. Have tried dynamically but coudn't use GroupBy, so from the static, I can use either the Key, or the property Date. Tried to convert it in C# but it would appear that the Umbraco Long date is a different form to MVC Long date.
    It seems like the hard part was done but have been stuck on this for a day - if anyone could add something to achieve a date time format from what I have or achieve another way, it would be very much appreciated.
    Best regards G

  • p.kidd 15 posts 55 karma points
    May 16, 2013 @ 23:59

    Did you get anywhere with the date formatting?

  • gary 385 posts 915 karma points
    May 17, 2013 @ 00:15


    i did get this working, so the answer is yes.

    however i am writing this on my phone as a combination of sql server and webmatrix 3 killwd my machine stone dead.

    i may be able to get he answer via the phone, but before i go looking, was it a group by as above using key that you need, or is it.just a striaght date format?

    Sorry to ask to be specific, but am a but will help all i can



Please Sign in or register to post replies

Write your reply to: