  We generalise the local index formula of Connes and Moscovici to the case of
spectral triples for a *-subalgebra \A of a general semifinite von Neumann
algebra. In this setting it gives a formula for spectral flow along a path
joining an unbounded self adjoint Breuer-Fredholm operator, affiliated to the
von Neumann algebra, to a unitarily equivalent operator. Our proof is novel
even in the setting of the original theorem and relies on the introduction of a
function valued cocycle which is `almost' a (b,B)-cocycle in the cyclic
cohomology of \A.
