Why do dead bodies stay for 24hours before floating??

Most of the time the floating is due to deterioration/decay of the body tissues and gases (CH4, H2S, and CO2) are produced, hence reducing the overall density of the body.

Read more about it, for example:
http://www.slate.com/articles/news_and_politics/explainer/2005/09/dead_mans_float.html