C#获取指定日期时间是当前年度的第几个季度
C#获取指定日期时间是当前年度的第几个季度
C# Code:
/// <summary>
/// C#获取指定日期时间是当前年度的第几个季度
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public static int GetQuarterNum(DateTime dt)
{
int year = dt.Year;
int jd;
DateTime dt0 = new DateTime(year, 1, 1);
DateTime dt1 = new DateTime(year, 4, 1);
DateTime dt2 = new DateTime(year, 7, 1);
DateTime dt3 = new DateTime(year, 10, 1);
if (dt.CompareTo(dt1) < 0)
jd = 1;
else if (dt.CompareTo(dt2) < 0)
jd = 2;
else if (dt.CompareTo(dt3) < 0)
jd = 3;
else
jd = 4;
return jd;
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
/// <summary>
/// C#获取指定日期时间是当前年度的第几个季度
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public static int GetQuarterNum(DateTime dt)
{
int year = dt.Year;
int jd;
DateTime dt0 = new DateTime(year, 1, 1);
DateTime dt1 = new DateTime(year, 4, 1);
DateTime dt2 = new DateTime(year, 7, 1);
DateTime dt3 = new DateTime(year, 10, 1);
if (dt.CompareTo(dt1) < 0)
jd = 1;
else if (dt.CompareTo(dt2) < 0)
jd = 2;
else if (dt.CompareTo(dt3) < 0)
jd = 3;
else
jd = 4;
return jd;
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网