Long enough to realize you should’ve pursued an MS.
In truth, you could likely finish in 1–2 years, depending on how much CS you’d covered in your CE undergrad.
Your math and science requirements would likely be covered. Some exceptions might include a Discrete Math course you need, or an additional science credit you have to earn. It’s likely you already completed courses in digital logic, microprocessors, operating systems, and computer architecture. You’d still need to take programming courses, a course or courses on Data Structures & Algorithms, a software engineering course, quite possibly Assembly, perhaps a course on object-oriented design, and electives in things like networks, security, ML, etc. (unless the elective requirement was satisfied by your CE electives).
It’d be a waste. In 1–2 years you can get an MS, which is worth far more than a B.S. in CS.
Who would you hire: the guy with CE and CS undergrad degrees, or the guy with a bachelor’s in CE and a master’s in CS?