1

I have a form load function and In the form I have two date fields _Datefrom and _Dateto. I want to set these fields as the beginning and end date of the month. So for example if the current month is February, I want to set it as

_DateFrom = 2/1/2016

and

_Dateto = 2/29/2016
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
Akansha
  • 199
  • 2
  • 11

1 Answers1

2

This should do it

Dim dateFrom = New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)
Dim dateTo = datefrom.AddMonths(1).AddDays(-1)
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
  • Thanks! But I have one more question: I am relating two fields Duedate and completed date to the Date from and to fields. On this, the Duedate is set as fuzzy date on the backend and I am not sure about how to convert it to date field. – Akansha May 10 '16 at 16:53