So I found a website that repeats this number -
https://www.uswings.com/about-us-wings/vietnam-war-facts/
But it's worth pointing out the actual statistic is, "The average infantryman in the South Pacific during World War II saw about 40 days of combat in four years. The average infantryman in Vietnam saw about 240 days of combat in one year thanks to the mobility of the helicopter."
An infantryman in the South Pacific is a very specific set of circumstances. An infantryman in Vietnam is a very broad set of circumstances. In other words, I don't think we can attach all that much significance to either number.
I guess I’ll just say this in conclusion - I think the only real way to reach a meaningful conclusion would be to compare what an infantry soldier could “expect” to experience in terms of combat while on the front lines (regardless of how long or frequent that time on the front lines is).
The experience of soldiers in the campaigns of 1864 and 1865 of extended time spent under fire was notable as being a departure from the normal experience.
For soldiers in WWII and Vietnam, the normal experience/expectation was to be on the line for an extended time under fire. (Yes you can find examples of the opposite - of Marines in the Pacific thinking the artillery and planes had killed all of the Japanese soldiers before they landed for example - but I'm speaking in general terms).
Time between campaigns, strategy, unit casualty rates, and other factors could and did impact the total number of days a soldier was in combat.
But in 1861-1863, the average soldier when on the “front lines” could expect maybe 5-10 days of low to extremely high intensity combat a year and the rest of the time to be spent marching and sitting in camp. At most, no more than a week of those days would be continuous, and usually no more than three days. In 1864-1865 soldiers could expect longer periods of low intensity combat lasting a month or more (sitting in the trenches at Petersburg for example) punctuated by a small number of extremely high intensity days, usually not lasting more than a day or two at a time continuously (such as an attempted breakthrough or a maneuver to cut a rail line). I don’t think there are many examples of regiments during the civil war suffering devastating casualties for more than a day or two at a time continuously.
Throughout all of WWII a soldier on the “front lines” could expect extended periods of continuous low intensity combat (holding a line or advancing through a sparsely defended area) punctuated by several days, weeks, even months of continuous high intensity combat (taking a city like Aachen, fighting in the Hurtgen Forest, or the Battle of Tarawa for example). The amount of time they would spend continuously in combat would depend on the strength of the enemy force and the difficulty of the terrain.
Vietnam soldiers could expect a lot of low intensity combat (daily patrols marked by short, sharp firefights or sniper fire) and a few several week to month to several month long high intensity experiences (Siege of Khe Sanh, Siege of Con Thien, Battle of Hamburger Hill, etc.)
As for how many days they would be on those “front lines” there are too many factors to consider - branch, theater, time period, etc. The 1st Marine Division fought 4 campaigns during WWII - Guadalcanal, Cape Gloucester, Peleliu, and Okinawa. The 5th Marine Division fought 1 - Iwo Jima, which was a month straight of pretty much continuous high intensity combat.
Outside of these broad terms, I think there are too many outside factors to meaningfully compare "days in combat" between wars (or even within a war to be honest).
Disclaimer: None of this is meant to minimize the sacrifice of any service members in any wars. Any experience of combat is a life-altering experience no matter the intensity.