Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8179307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:58:24+00:00 2026-06-06T23:58:24+00:00

I am trying to create a archive list for a blog application. I have

  • 0

I am trying to create a archive list for a blog application. I have a veiw model which has this code snippet:

@model IEnumerable<NPLHBlog.Models.ArchiveListModels>
...
        @foreach (var item in Model)
        {
            <li>@item.ArchiveMonth/@item.ArchiveYear : @item.PostCount</li>
        }
...

I am trying to print the item.ArchiveMonth as ‘Jan’ instead of ‘1’.

the ArchiveListModel is as follows:

public class ArchiveListModels
{
    public int ArchiveYear { get; set; }
    public int ArchiveMonth { get; set; }
    public int PostCount { get; set; }
}

and blogs are read from repository as follows:

    public IQueryable<ArchiveListModels> ArchiveList()
    {
        var archiveList = from blogs in db.Blogs
                          group blogs by new { blogs.PublishDate.Year, blogs.PublishDate.Month }
                              into dateGroup
                              select new ArchiveListModels()
                              {
                                  ArchiveYear = dateGroup.Key.Year,
                                  ArchiveMonth = dateGroup.Key.Month,
                                  PostCount = dateGroup.Count()
                              };
        return archiveList;
    }

Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:58:25+00:00Added an answer on June 6, 2026 at 11:58 pm

    To get the full month name

    int month = 1;
    System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.GetMonthName(month);
    

    Or you can use the datetime string format:

    int month = 1;
    var dt = new DateTime(2012, month, 1):
    var monthAbbr = dt.ToString("MMM");
    

    Or you can do a lookup against the abbreviations list

    int month = 1;
    var monthAbbr =     System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.AbbreviatedMonthNames[month];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an 'archive'-page for my blog. It should list all blog
I have a project whereby I'm trying to create a distribution zip file, which
I'm trying to create something almost similar to this [1]: http://weblogs.asp.net/infinitiesloop/archive/2007/09/17/inline-script-inside-an-asp-net-ajax-updatepanel.aspx The problem I
Trying to reinvent a wheel with a archive list, got this so far jsfiddle
i'm trying to create dynamically generated icon list for tiny mce. I have written
I am trying to create an add-in by using the article below http://blogs.microsoft.co.il/blogs/shair/archive/2008/07/28/how-to-create-sql-server-management-studio-addin.aspx I
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Trying to create a macro which can be used for print debug messages when
Trying to create a background-image slideshow and am getting this error... This is the
I'm trying create a scaling layout for an Android application. The whole screen should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.