Copied to clipboard

Flag this post as spam?

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


  • Manasa 80 posts 201 karma points
    Nov 27, 2014 @ 13:29
    Manasa
    0

    to eliminate replicated copies

    Hi All,

     

    I want to eliminate replicated copies of month and year from the date i get.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

     

    @{

        var blogs = Umbraco.TypedContentAtRoot().DescendantsOrSelf("ArticulateRichText").OrderBy("publishedDate desc");

     

        List<DateTime> dateList = new List<DateTime>();

     

        foreach (dynamic blog in blogs)

        {

            DateTime date = blog.GetPropertyValue<DateTime>("publishedDate");

            //var year = @String.Format("{0:yyyy/MM}", date);

            //var month = year.ToString("MMMM yyyy");

     

            dateList.Add(@date);

     

        }

     

     

     

        List<DateTime> unique = dateList.Distinct().ToList();

        <ul>

            @foreach (dynamic m in unique)

            {

                <li><a>@m.ToString("MMMM yyyy")</a></li>

            }

        </ul>

    }

     

           How can i do it?

     

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft