No, Gandalf makes it clear that he entered Moria in search of the missing Thráin, so it had to be after TA 2845 and might even had been after his investigation of Dol Guldur five years later. It also had to have been before Gandalf's encounter with Thorin in Bree in March of 2941.Wbweather wrote:Gandalf may have visited Moria in the height of its glory and not needed to open the western gate. Since 1000 years have past since it fell, it would make sense that he might struggle remembering the way through as he seems to do in the books.
Gandalf gives us no reason to think that he ever visited Khazad-dûm in the days when Durin's Folk still dwelt there. But even if he had--as you point out--that would have been over one thousand years before the War of the Ring.'In the ruins of the Dwarves, a dwarf's head will be less easy to bewilder than Elves or Men or Hobbits. Yet it will not be the first time that I have been to Moria. I sought there long for Thráin son of Thrór after he was lost. I passed through, and I came out again alive!'