Assuming you are talking about a 24 volt battery, there are a few things that will affect how long it lasts. One is the type of battery - lead acid batteries will last longer than lithium ion batteries, for example. Another is how many amp hours the battery has - this will be listed on the battery itself and will give you an indication of how long it can power something for. Finally, how you use the battery will also affect its lifespan - if you regularly discharge it fully then it won't last as long as if you only use a portion of its capacity each time.
In general, though, a 24 volt lead acid battery should last around 3-5 years with regular use. Lithium ion batteries may only last 2-3 years, but they have the advantage of being lighter and easier to transport.