ASP.NET

ASP.NET 날짜비교

이빛나리 2012. 1. 26. 17:01


DateTime d1 = DateTime.Parse("2012-01-22");
DateTime d2 = DateTime.Parse("2012-02-07");
                
 if (DateTime.Compare(d1, d2) > 0)
 if (DateTime.Compare(d1, d2) == 0)
 if (DateTime.Compare(d1, d2) < 0)               
{
          Response.Write("d1 > d2");
          Response.Write("d1 == d2");
          Response.Write("d1 < d2");
 }

Compare: 두 인스턴스를 비교하여 첫 번째 인스턴스와 두 번째 인스턴스보다 빠른지 느린지 같은지를 나타내는 정수를 반환한다.