  We present a gravitoelectric quadrupolar dynamical tidal-interaction
Hamiltonian for a compact binary system, that is valid to second order in the
post-Newtonian expansion. Our derivation uses the diagrammatic effective field
theory approach, and involves Feynman integrals up to two loops, evaluated with
the dimensional regularization scheme. We also derive the effective Hamiltonian
for adiabatic tides, obtained by taking the appropriate limit of the dynamical
effective Hamiltonian, and we check its validity by verifying the complete
Poincar\'e algebra. In the adiabatic limit, we also calculate two
gauge-invariant observables, namely, the binding energy for a circular orbit
and the scattering angle in a hyperbolic scattering. Our results are important
for developing accurate gravitational waveform models for neutron-star binaries
for present and future gravitational-wave observatories.
