Apparently it's from German around 1780, for the time during the summer when the cucumbers ripen, everyone is on vacation, and business is slow. That's what the Danish wikipedia entry says, at least.
The Dutch Wikipedia mentions English, German or Jiddisch as possible sources: https://nl.wikipedia.org/wiki/Komkommertijd