Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
May i know
how to get last date of current year in vb.net.

eg. last date of this year =31/12/2012
Posted
Comments
ZurdoDev 23-Jul-12 10:21am    
The last day is always December 31 and since you want the current year, just use the year of Now. It's pretty easy.

VB
new DateTime(DateTime.Now.Year, 12, 31)
 
Share this answer
 
v3
Comments
Espen Harlinn 24-Jul-12 4:34am    
5'ed!
Try this:
Function for getting year:
VB
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:
VB
Dim d As New DateTime(2012, 7, 1)
    Console.WriteLine("Last day of 2012: {0}", LastDayOfYear(d))

Ref.:DateTime VB.NET[^]

Also have a look on:
DateTime.Year Property[^]
DateTime.DayOfYear Property[^]
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900