Can anyone please tell me how to get all days and date of selected month from calendar in .net.This is to create attendance of employees. I need each days and date of the selected month to be displayed in label box.Like sun,mon,tue etc ...and 1,2,3....28 or 29 or 30 or 31 based on the month and year I selected. Thanks in advance.
const int MONTH = 5; // write out all the days of May 2015 DateTime dt = new DateTime(2015, MONTH, 1); while (dt.Month == MONTH) { Console.WriteLine(dt.ToString("ddd dd")); dt = dt.AddDays(1); }
public List<datetime> GetDates(int year, int month) { return Enumerable.Range(1, DateTime.DaysInMonth(year, month)) // Days: 1, 2 ... 31 etc. .Select(day => new DateTime(year, month, day)) // Map each day to a date .ToList(); // Load dates into a list }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)