Detection of very weak forces and precise measurement of time are two of the many applications of quantum metrology to science and technology. To sense an unknown physical parameter, one prepares an initial state of a probe system, allows the probe to evolve as governed by a Hamiltonian H for some time t, and then measures the probe. If H is known, we can estimate t by this method; if t is known, we can estimate classical parameters on which H depends. The accuracy of a quantum sensor can be limited by either intrinsic quantum noise or by noise arising from the interactions of the probe with its environment. In this work, we introduce and study a fundamental trade-off, which relates the amount by which noise reduces the accuracy of a quantum clock to the amount of information about the energy of the clock that leaks to the environment. Specifically, we consider an idealized scenario in which a party Alice prepares an initial pure state of the clock, allows the clock to evolve for a time that is not precisely known, and then transmits the clock through a noisy channel to a party Bob. Meanwhile, the environment (Eve) receives any information about the clock that is lost during transmission. We prove that Bob’s loss of quantum Fisher information about the elapsed time is equal to Eve’s gain of quantum Fisher information about a complementary energy parameter. We also prove a similar, but more general, trade-off that applies when Bob and Eve wish to estimate the values of parameters associated with two noncommuting observables. We derive the necessary and sufficient conditions for the accuracy of the clock to be unaffected by the noise, which form a subset of the Knill-Laflamme error-correction conditions. A state and its local time-evolution direction, if they satisfy these conditions, are said to form a metrological code. We provide a scheme to construct metrological codes in the stabilizer formalism. We show that there are metrological codes that cannot be written as a quantum error-correcting code with similar distance in which the Hamiltonian acts as a logical operator, potentially offering new schemes for constructing states that do not lose any sensitivity upon application of a noisy channel. We discuss applications of the trade-off relation to sensing using a quantum many-body probe subject to erasure or amplitude-damping noise.