Depends which sim one you are using.
When I had Microsoft Train Simulator (2001) I usually made myself custom freight scenarios that involved a lot of shunting and stuff and could basically go on for quite a bit of time. There's no real limit.
Edit: Also custom tracks could be really really long.