CSharp examples for System:DateTime Day
Get Last Friday
using System.Text; using System.Linq; using System.Collections.Generic; using System;/* w w w . j av a 2 s .co m*/ public class Main{ private static DateTime GetLastFriday(DateTime d) { DateTime dd = new DateTime(d.Year, d.Month, d.Day, 15, 05, 0); int c = 0; if (d.DayOfWeek >= DayOfWeek.Friday) { c = 5 - (int)d.DayOfWeek; } if (d.DayOfWeek < DayOfWeek.Friday) { c = -2 - (int)d.DayOfWeek; } return GetEndTradeTime(dd.AddDays(c)); } }