FUNCTION ChooseDate()
local y ld
  while true
'     monthend = right(today,5)
    monthend = right(today,7)
    x = fentrybox(" Confirm month for"&$shop_name|"'s report ",7,"*2#\/*4#",monthend)
    if x = 0
      monthend = ptstr
      fullmonth = "01/"|ptstr
      x = chkdate(fullmonth,1)
      if x = 0
        y = len(date3(fullmonth))
        y = y - 8
        briefmonth = monthname(fullmonth)|" '"|right(fullmonth,2)
        exit while
      else
        messbox(" Incorrect date - re-enter ",0,0,1)
      end if
    else
      return (-1)
    end if
    briefmonth = left(date3(fullmonth),3)
  end while
  for ld = 31 to 28 step -1
    enddate = str(ld)|"/"|monthend         'message "last_m_e is:"&str(last_m_e)
    if chkdate(enddate,1) = -1
      continue for
    else
      exit for
    end if
  end for
' message "enddate is:"&date3(enddate)
END FUNCTION 'Date()
