Welcome to healthcaremagic.
in 17 month old is usually due to infection, most commonly viruses. It usually recovers with symptomatic and supportive treatment along with increased oral intake of fluids.
Bacteria can also cause diarrhoea. However, it needs to be proven by doing a stool test
. If the stools are very smelly, mucousy, presence of blood, fever
etc are signs that it could be bacterial infection.
Babies can get Giardia, as at this age group, they do eat food other than homemade cooked meal.
With the history of diarrhoea on and off for over a period of 4 weeks, I would suggest to get his stool tested. Depending on the results, he may need antibiotics to clear bacteria/protozoa infection.
Hope I have resolved your query