Dim SelectedDate As Date = Today
Dim FirstDayOfWeekDate As Date = SelectedDate.AddDays(SelectedDate.DayOfWeek * -1)
Dim LastDayOfWeekDate As Date = FirstDayOfWeekDate.AddDays(6)
Dim FirstDayOfMonthDate As Date = New Date(SelectedDate.Year, SelectedDate.Month, 1)
Dim LastDayOfMonthDate As Date = New Date(SelectedDate.Year, SelectedDate.Month, Date.DaysInMonth(SelectedDate.Year, SelectedDate.Month))
Dim FirstDayOfYearDate As Date = New Date(SelectedDate.Year, 1, 1)
Dim LastDayOfYearDate As Date = New Date(SelectedDate.Year, 12, Date.DaysInMonth(SelectedDate.Year, 12))
Dim DaysInTheYear As Integer = New Date(SelectedDate.Year, 12, Date.DaysInMonth(SelectedDate.Year, 12)).DayOfYear
Tips and tricks for .NET using ASP and VB code.
Calculate first and last day of week, month, year
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment