CSharp examples for System:DateTime Week
Last Weekend Date
using System.Text; using System.Linq; using System.Collections.Generic; using System;//from www . j a va 2s .c om public class Main{ public static DateTime LastWeekendDate(this DateTime date) { if (date.DayOfWeek == System.DayOfWeek.Sunday) return date.Date.AddDays(-7); else return date.Date.AddDays(0 - (int)date.DayOfWeek); } public static int DayOfWeek(this DateTime date) { if (date.DayOfWeek == System.DayOfWeek.Sunday) return 7; else return (int)date.DayOfWeek + 1; } }