The latest Newsweek reports on the length of American wars. By their accounting:
Vietnam War 8 years, 5 months, 21 days
American Revolution 8 years, 4 months, 16 days
War in Afghanistan 7 years, 11 months, 22 days
Iraq War 6 years, 6 months, 9 days
World War II 6 years, 2 days
World War I 4 years, 3 months, 15 days
Gulf War 1 months, 13 days
War is a battle to invade or repel an invasion. It may or may not topple a government when it is over. At its conclusion, either a government has surrendered or two governments have negotiated a peace.
Occupation is a battle to rule a people. There is only one official government. If there is no government change to come, no opposing army to surrender, and no land to conquer or give up, there is no way to "date" the end of that battle.
The War in Afghanistan threatens to become the longest American war because it is an occupation. You can date the fall of Iraq or the Taliban supported government in Afghanistan. By that measure the wars were short. There is no good way to date the end of the occupation - or even a good way to end an occupation.
[It's worth noting that the American Revolution also ended with victory on the side of the lesser power whose chief advantage was that they had no where else to go as they battled an occupying force.]