CSharp examples for System:DateTime Week
Last Two Weeks End Date
using System.Text; using System.Linq; using System.Collections.Generic; using System;//from w w w. j av a 2s. com public class Main{ public static DateTime LastTwoWeeksEndDate(this DateTime date) { if (date.DayOfWeek == System.DayOfWeek.Sunday) return date.Date.AddDays(-14); else return date.Date.AddDays(0 - (int)date.DayOfWeek - 7); } public static int DayOfWeek(this DateTime date) { if (date.DayOfWeek == System.DayOfWeek.Sunday) return 7; else return (int)date.DayOfWeek + 1; } }