询问日期时间 [英] asking about date time
本文介绍了询问日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以知道吗
如何在vb.net中获取当年的最后日期.
例如.今年的最后日期= 31/12/2012
May i know
how to get last date of current year in vb.net.
eg. last date of this year =31/12/2012
推荐答案
new DateTime(DateTime.Now.Year, 12, 31)
试试看:
获取年份的功能:
Try this:
Function for getting year:
Private Function LastDayOfYear(ByVal d As DateTime) As DateTime
Dim time As New DateTime((d.Year + 1), 1, 1)
Return time.AddDays(-1)
End Function
调用函数:
Calling Function:
Dim d As New DateTime(2012, 7, 1)
Console.WriteLine("Last day of 2012: {0}", LastDayOfYear(d))
参考号: DateTime VB.NET [ DateTime.Year属性 [ DateTime.DayOfYear属性 [
Ref.:DateTime VB.NET[^]
Also have a look on:
DateTime.Year Property[^]
DateTime.DayOfYear Property[^]
可以获取天数一个月.
to get the no of days in a month.
<br />
int days = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);<br />
最终将显示您当前月最后一个日期的要求.
ultimately the requirement of your last date of current month will shown.
这篇关于询问日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文