It's already been said that dating the individual grains would yield the date that the parent rock formed, many years before the sedimentary or metamorphic rock formed. So scientists are smart enough to avoid doing that.
However, there are some methods for dating when sedimentary rock formed. Not surprisingly they involve dating the "glue" that holds the rock together. The individual grains of sedimentary rock don't stick together by themselves; something forms or precipitates between the grains and holds them together.
Examples include U-Pb dating of xenotime grown on zircons (
SHRIMP Uranium-Lead Dating of Diagenetic Xenotime in Siliciclastic Sedimentary Rocks) and K-Ar dating of glauconite (
Sedimentary geology: an introduction to sedimentary rocks and stratigraphy, pg 400). The latter is not particulary reliable because argon loss is common, leading to dates that are 10-20% too low (but still incompatible with creationist time scales by orders of magnitude).
Most sedimentary rocks, and the fossils they contain, are dated by a combination of stratigraphy, index fossils, and radiometric dating.
The simplest case is a fossil found in a sedimentary layer that lies between two igneous layers. Suppose the igneous layer above is dated at 500 million years and the layer below is dated as 510 million years; the sedimentary layer and fossil are therefore 500 to 510 million years old. This situation is common, such as in the Rift Valley of East Africa, where so many hominid fossils have been found; the area is loaded with volcanic tuff layers.
An example of a slightly more complex case is the use of index fossils to
calibrate, not
date, layers. An index fossil is a fossil of an organism that has been found to occur only in some narrow range of dates (by many applications of the technique above). FOr example
foraminifera, AKA forams, are widely used and are critical to oil well drilling. Let's suppose we know of an index fossil that is reliably known to be 370-380 million years old. Also suppose we find a fossil of some other organism in a layer that's above a layer containing those index fossils and below an igneous layer that dates to 350 million years. The new fossil is therefore 350-370 million years old.
There are lots of scenarios and variations, but the bottom line is that most fossils are dated by radiometric dating of associated igneous layers, the association being established by various means.