Code for getting the Current month's first date and last date using Tuple in

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 129
The below code will do so

Namespace ConsoleApplication1
Class Program
Private Shared Sub Main(args As String())
Dim dt = GetCurrentDate()
Dim stDT = dt.Item1
Dim etDT = dt.Item2
End Sub

Private Shared Function GetCurrentDate() As Tuple(Of DateTime, DateTime)
Dim [date] As DateTime = DateTime.Now
Dim firstDayOfMonth = New DateTime([date].Year, [date].Month, 1)
Dim lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1)
Return Tuple.Create(firstDayOfMonth, lastDayOfMonth)
End Function
End Class
End Namespace

Comments or Responses

Login to post response