Back in the day, I worked on the pieces for my university senior recital from September through May. My (memorized) program consisted of these works:
J.S. Bach Prelude & Fugue No. 5 in D Major (WTC Book 1)
Beethoven Sonata No. 18 Op. 31, No. 3
Chopin Grande Valse brillante Op. 18
Chopin Preludes Op. 28, Nos. 15, 17, 18
Liszt Valse oubliee No. 1
Debussy Reflets dans l'eau
Debussy Jardins sous la pluie
For a long time, that had been the longest (eight months) that I'd ever spent preparing any piece or group of pieces for performance, because after that, I didn't do any solo piano performing for something like 25 years.
Now that I'm back to performing -- at my more advanced age
-- it takes me longer to prepare pieces from memory. (And sometimes I use music. I play in piano concerts with other local pianists about three times a year, and most don't memorize.)
But to get back to the original question about the longest time ever spent learning a piece, I just broke my old record of eight months from my university years by spending about ten months preparing to perform Schubert's Fantasie in F Minor, Op. 103 with my duet partner. I started working alone on the primo last June, and, with the exception of one meet-up with my partner last October, I spent about seven months in studying my own part, and then added in three months of sessions with my duet partner about once or twice a week from January to early April of this year.
We performed it (with music) on April 7, and got a standing ovation -- the first one either or both of us had ever gotten.
I would say the time we spent on it was worth it.
We love the piece so much, we plan to perform it again in a recital next year.
How did that experience with the duet change me? Well, I'd say it helped me see the value of maintaining a work after a performance is finished, and using the work again in the future, rather than preparing for performance after performance, never to return to anything previously performed. There's value in keeping repertoire alive, or revisiting it for future performances, rather than starting over with something new each time one performs.