The trip takes around 18 hours, depending on if you travel via Uyuni or via Oruro. The exact time depends also on how long it takes to do the paperwork at the border.