2012-03-05 55 views
1

在我第一次创造了支付期的时间表,这是该类型为每月,例如,开始,结束,交易和收费期限的功能是象下面这样:我要生成payperiod每月

  1. 01-JAN-12 12:00 AM,30-JAN-08上午11时59,31-JAN-08 12:00 PM

上面一个是第一个月payperiod。下个月它会自动创建并插入到数据库中,我会怎么做?

  1. 01 - 2月 - 12 12:00 AM,28月12日晚上11:59,29月12日下午12:00

请帮助我..

+0

http://stackoverflow.com/questions/2186794/how-can-i-get-correct-payperiod-from-date – Jason 2012-03-05 07:35:24

+0

请阅读我更新的问题.. – Fernando 2012-03-05 07:39:19

回答

0
for (int i = 1; i <= 12; ++i) 
{ 
    DateTime firstDate = new DateTime(2012, i, 1, 0, 0, 0); 
    int daysInMonth = DateTime.DaysInMonth(2012, i); 
    DateTime endDate = new DateTime(2012, i, daysInMonth-1, 23, 59, 59); 
    DateTime TransactionDate = new DateTime(2012, i, daysInMonth, 0, 0, 0); 
    Console.WriteLine(firstDate.ToString() + 
       "," + endDate.ToString() + 
       "," + TransactionDate.ToString()); 
} 
+0

感谢您的快速回复。它返回以下错误{System.ArgumentOutOfRangeException:Year,Month和Day参数描述不可表示的DateTime。 – Fernando 2012-03-05 08:49:18

+0

@Fernando对不起,我编辑了代码时出错了。 – 2012-03-05 09:07:01