How long did Jesus, Joseph, and Mary live in Egypt?
Around 3 months.
Jesus, Joseph, and Mary departed to Egypt after Mary purification. This put their departure in February 4 BC Julian Calendar, as discussed in “When did Jesus, Mary, and Joseph go to Egypt?“. They lived in Egypt until Herod death in April 4 BC Julian Calendar. Assuming their arrival at Egypt in the same month as their departure, they then had lived in Egypt for around three months from February to April 4 BC Julian Calendar.