我的守则是:
DateTime startDate = Convert.ToDateTime( orderDate ).AddMonths(-1);
DateTime endDate = Convert.ToDateTime( orderDate );
命令 日期是我通过的日期。
How do I always guarantee startDate is the first day of the previous month for orderDate? How do I always guarantee endDate is the last day of the month for orderDate?
例:
orderDate = 5/4/2012
I want startDate to be 4/1/2012 (or 04/1/2012 whichever is default)
I want endDate to be 4/30/2012
我怎么能够这样做?