如何找到当月的前几个月 [英] how to find Previous months of the current month
本文介绍了如何找到当月的前几个月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何找到当月的前几个月
i得到DEC-2012
i需要2012年11月
和2012年10月
使用日期时间或任何代码片段请帮助我。 ...
how to find the previous months of the current month
i got as DEC-2012
i need Nov-2012
and Oct-2012
using datetime or any code snippets please help me....
推荐答案
检查这个
Hi ,
Check this
string prevMont= DateTime.Now.AddMonths(-1).ToString();
最好的问候
M.Mitwalli
Best Regards
M.Mitwalli
尝试:
Try:
DateTime now = DateTime.Now;
DateTime lastMonth = now.AddMonths(-1);
DateTime twoMonthsAgo = now.AddMonths(-2);
这篇关于如何找到当月的前几个月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文