If you oxygenate the water (air pump) you could keep the fish in there for quite a long time, depending on how many fish you tried to squeeze into one bucket. If you don't try to put too many into one bucket you could potentially keep them there for several days. Remember fish are shipped in little bags filled with water and pure oxygen, and are often in these bags at least one day. As long as you oxygenate your fish will be okay. And don't feed them in the bucket and try to avoid feeding them for a few hours prior to putting them in the bucket. Your fish will be fine for how long it should take to change from gravel to sand! Even if it takes you a couple hours.
\Dan