c#분기별 인스턴스 코드 가져오기(분기별 첫날)

1627 단어
 
  
string firstDayOfThisQuarter = DateTime.Now.AddMonths(0-(DateTime.Now.Month - 1)%3).ToString("yyyy-MM-01");
Console.WriteLine(" :{0}",firstDayOfThisQuarter);

string lastDayOfThisQuarter = DateTime.Parse(DateTime.Now.AddMonths(3 - ((DateTime.Now.Month - 1)%3)).ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString();
string lastDayOfThisQuarter2 = DateTime.Parse(DateTime.Now.AddMonths(3 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01")).AddDays(-1).ToString("yyyy-MM-dd");
Console.WriteLine(" :{0}", lastDayOfThisQuarter);
Console.WriteLine(" :{0}", lastDayOfThisQuarter2);

string firstDayOfNextQuarter = DateTime.Now.AddMonths(3 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01");
string lastDayOfNextQuarter = DateTime.Parse(DateTime.Now.AddMonths(6 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString();
Console.WriteLine(" :{0}", firstDayOfNextQuarter);
Console.WriteLine(" :{0}", lastDayOfNextQuarter);

string firstDayOfLastQuarter = DateTime.Now.AddMonths(-3 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01");
string lastDayOfLastQuarter = DateTime.Parse(DateTime.Now.AddMonths(0 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString();
Console.WriteLine(" :{0}", firstDayOfLastQuarter);
Console.WriteLine(" :{0}", lastDayOfLastQuarter);

좋은 웹페이지 즐겨찾기