Forty-day fasts come pretty close to the limit of what the body can tolerate. In my spiritual tradition, your spiritual advisor would want to be very sure of your reasons for engaging in such a fast before permitting it. (For example, the desire to take pride in such an achievement would not be considered a healthy motivation.)
The one really long-term medical fast I know of was the case of Angus Barbieri, a grossly overweight Glaswegian 27-year-old, who fasted for 382 days. The fast was originally intended to be much shorter, but he persuaded his doctors to allow him to continue, and they agreed, so long as he came in regularly for checkups.
The case was written up by Stewart & Fleming, “Features of a successful therapeutic fast of 382 days’ duration,” Postgraduate Medical Journal (March 1973), 49:203–209. The authors begin by noting that
Current opinion on fasting therapy for the obese is perhaps best summarized by the view that fasting for relatively short periods is beneficial, whereas longer term fasting (i.e. longer than 40 days) has an element of risk attached (Lawlor & Wells, 1971). It is generally agreed that the long-term outlook for the achievement and maintenance of ideal body weight is poor (MacCuish, Munro & Duncan, 1968; Lawlor & Wells 1971) unless a weight close to the ideal is achieved during the supervised phase (Munro et al., 1970), a process which in the majority of cases would involve a prolonged rather than a short-term fast."
They then go on to describe Mr. Barbieri’s experience and the treatments and tests administered during the fast. He weighed 456 lb./207.3 kg before undertaking the fast. “Initially, there was no intention of making his fast a protracted one, but since he adapted so well and was eager to reach his ‘ideal’ weight, his fast was continued into what is presently the longest recorded fast.” He was given vitamin supplements daily, along with vitamin C and yeast. Non-caloric fluids were allowed ad libitum. At one point he received potassium supplements, at another sodium. At the end of his fast, Mr. Barbieri weighed 180 lb./81.8 kg, and his weight remained stable at 196 lb./89.1 kg five years later.