الگوریتم کم کردن روز از یک تاریخ البته یکم نامرتبه :

int day =date.Day;
int month = date.Month;
int year=date.Year;
//if day >30 then calcute mounth cut count.
if (days > 30)
{
day =(days % 30);
month=(days / 30);
//if mounth > this mean to this date of last years
if (month >=date.Month )
{
month = 12-(month-date.Month);
year = date.Year - 1;
}
if (day >= date.Day)
{
day = day - date.Day;
month=date.Month-1;
if (month < 1)
{
month = 12;
year = date.Year - 1;
}
}
}
else if (days < 30)
{
day = date.Day - days;
//if day<0 this mean to this date of last mounth
if (days >= date.Day)
{
day = 30 - (days - date.Day);
month = date.Month - 1;
if (month < 1)
{
month = 12;
year = date.Year - 1;
}
}
}