Reflective optical sensor
&quot;Daylight&quot; is full of various wavelengths of light, including infrared.
In daylight, your sensor will &quot;see&quot; infrared from the mishmash that is sunlight, and react the same as if it were seeing the reflected infrared from its emitter.
To make things worse, the detector can also &quot;see&quot; normal light as well as infrared.  It has a filter (the lenses of detector and emitter are dark colored, that's the filter)  to reduce the amount of visible light that the detector sees.  Daylight is bright, though, so enough daylight can get in to make the situation worse.
The sensor can't tell daylight from the emitted infrared.
You have to make the emitted infrared &quot;look&quot; different from daylight.
The usual way to do this is to power the emitter in pulses, then look for the pulses in the detector.
There are infrared detectors that look for the typical 38kHz pulses used in infrared remote controls (like TVs have.)  These detectors output a digital low when they see a 38kHz infrared signal, and a high when no 38kHz is visible.
The simplest thing to do would be to get a module that includes a pulsed emitter and a 38kHz detector.  Pololu makes such a module, or you can build your own.
To build your own,the easiest path would be to generate the 38kHz pulse signal from the microcontroller that's probably already part of your project already.  Use that (through a transistor) to drive the infrared LED.
If you don't have a microcontroller in your project, then you can use a simple oscillator like the Polulu module does.  A 555 or other oscillator at 38kHz and a transistor is all it takes to drive the emitter.
Use something like the Vishay TSSP58038 IR to detect reflections.
There are many parts available for both the emitter and detector.  The ones I've named arw just the first examples that Google coughed up.

There's nothing that says you can't select your own pulse frequency and design an emitter and demodulator that will work with your current sensor.  It is just much easier to latch on to existing components.