Mega Code Archive

 
Categories / C# / Date Time
 

Get the quarter number for the DateTime

//Octavalent Extension Methods //http://sdfasdf.codeplex.com/ //Library of extension methods for .Net create by Octavalent (www.octavalent.nl) using System;     public static class DateTimeExtensions     {         public static int Quarter(this DateTime dateTime)         {             return Convert.ToInt16((dateTime.Month - 1)/3) + 1;         }    }