Can we use capacitors to be the input of an opamp? If we have a sensor and we store the value of the sensor in a capacitor, and we do that 2 different moments of the day (different capacitors) can we compare those 2 values? And how we will connect the capacitors to the opamp? Do we need to ground the plates with negative voltage?
Given a suitably modest accuracy requirement, large capacitor, high-impedance op-amp and low leakage conditions, it is nominally possible to do as you suggest. But it is unwise for anything more than a short period.
The main problem is that charge leakage will be unpredictable and may vary a great deal, with environmental conditions affecting the conductivity of the air and even condensation on the hardware. Dirt will accumulate after prolonged use and further degrade accuracy. Military-style encapsulation would help, but requires skill and experience to do well.
Charge-coupled devices (CCD), once widely used as camera sensors, are capacitance-based and implement a more complicated variant of just the principle you describe, but the charge need be stable only long enough for the CCD array to be read out into digital storage via an ADC, a time measured in seconds at most.
In practice you would do better to go down a similar route. And if you are doing that, why bother with the capacitors?
Can we use capacitors to be the input of an opamp?
Yes, you can connect charged capacitors to the op-amp (comparator) inputs. The only problem are the op-amp input bias currents that will charge (discharge) the capacitors. Fortunately, they are too small (nA). So, if your capacitors have significant capacitance... or if you make the measurement quickly enough, there will be no problem.
So your arrangement is quite simple - the two capacitors are grounded and connected to the two comparator inputs.
Of course, the "silly" solution to provide paths for the bias currents is to connect resistors with high resistance between the op-amp inputs and ground.
BTW there is a special "sample & hold" circuit designed for this purpose.