将整数值转换为Datetime(mmm-yyyy)格式。 [英] To Convert integer value into Datetime(mmm-yyyy) format.
本文介绍了将整数值转换为Datetime(mmm-yyyy)格式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我想将整数值转换为datetime(mmm-yyyy)格式可以帮助吗?
示例:我有整数值:6现在我想要将此6转换为2013年6月如何转换。
解决方案
尝试:
DateTime dtDate = new DateTime( 2013 , 6 , 1 );
string MonthName = dtDate.ToString( MMMM跨度>);
为了拥有日期时间,您至少需要三件事:一天,一个月和一年(时间可以推断是午夜)。你只有一个:月份。
所以其余部分必须由您的申请指定。我建议你试试这个:
int myMonth = 6 跨度>;
int thisYear = DateTime.Now.Year;
DateTime dt = new DateTime(thisYear,myMonth, 1 );
尝试
< pre > DateTime baseDate = new DateTime(1900,1,1);
DateTime newDate = baseDate.AddDays(numDays); < / pre > 跨度>
Hi i want to convert an integer value into datetime(mmm-yyyy) format can u help?
example: i have integer value :6 now i want to convert this 6 into Jun-2013 How can i convert.
解决方案
Try:
DateTime dtDate = new DateTime(2013, 6, 1); string MonthName= dtDate.ToString("MMMM");
In order to have a datetime, you need a minimum of three things: a day, a month, and a year (the time can be inferred to be midnight). You have only one: the month.
So the rest will have to be specified by your application. I suggest you try this:
int myMonth = 6; int thisYear = DateTime.Now.Year; DateTime dt = new DateTime(thisYear, myMonth, 1);
Try <pre>DateTime baseDate = new DateTime(1900, 1, 1); DateTime newDate = baseDate.AddDays(numDays);</pre>
这篇关于将整数值转换为Datetime(mmm-yyyy)格式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文