title: Functions to return week first date and week last date in current month
body: <p>I created a function to get first date of week as Thursday in MS Access form and reports, but it function returns first day of week in last month.</p>
  
  <p>I need it to return only current month dates. If current week first day is in last month then return first day of week as first date of week in current month.</p>
  
  <p>Current output</p>
  
  <p>When 1-10-2018 is selected from date picker it returns 27-09-2018, which is first date of week in last month but I need it will return first of month which is selected in textbox.</p>
  
  <pre><code>Function GetFirstofWeek(dtDate As Date)
      GetFirstofWeek = DateAdd("d", dtDate, -(Weekday(dtDate)) + 1)
           ' Excel formula for this function which is perfect and may be converted to function as required ‘=MAX(B2-WEEKDAY(B2,14)+1, EOMONTH(B2, -1)+1)
      GetFirstofWeek = DateAdd("d", dtDate, -(Weekday(dtDate, vbThursday) - 1)) 
  End Function
  </code></pre>
  
  <p>For last day of week</p>
  
  <pre><code>Function GetLastofWeek(dtDate) as date
      '=MIN(B2+(7-WEEKDAY(B2,14)), EOMONTH(B2, 0))
       ‘this excel formula return date as I need. 
        GetLastofWeek = DateAdd("d", dtDate, (7 - (Weekday(dtDate, vbWednesday)) + 1)) 
  
  End Function
  </code></pre>
  
  <p>In this function last date of week must be in current month, if month end on first date of then week will be closed and last date of week will be first date of week or days remaining in current week.</p>