CSharp examples for System:DateTime Quarter
First Date Of Quarter
using System.Globalization; using System;//from www . j av a 2 s. c o m public class Main{ public static DateTime FirstDateOfQuarter(this DateTime date) { var quarter = date.Quarter(); var month = (quarter - 1)*3 + 1; return new DateTime(date.Year, month, 1); } public static int Quarter(this DateTime date) { var month = date.Month; if (month < 4) return 1; if (month < 7) return 2; if (month < 10) return 3; return 4; } }