Following code snippet is will help you find our starting date and ending date of current month.
Dim Year As Integer = DateTime.Today.Year
Dim Month As Integer = DateTime.Today.Month
Dim stDate As DateTime
stDate = New DateTime(Year, Month, 1)
Dim endDate As DateTime
endDate = New DateTime(Year, Month, DateTime.DaysInMonth(Year, Month))
MessageBox.Show(stDate.ToString("dd/MM/yyyy"))
MessageBox.Show(endDate.ToString("dd/MM/yyyy"))
In the above code I have taken Current year in Year variable current month in Month. For start date of any month will be 1 so we can directly give Year, Month, 1 as parameters to create start date. For end date we have to get the current month end date for that we can use in built function DayInMonth and create end date.
Hope this helps
Tags : Start Date, End Date of Current Month in VB.NET
No comments:
Post a Comment