As indicated by the Sage Advice Compendium (2017):
Can you use dispel magic on the creations of a spell like animate dead or affect those creations with antimagic field?
Whenever you wonder whether a spell’s effects can be dispelled or
suspended, you need to answer one question: is the spell’s duration
instantaneous? If the answer is yes, there is nothing to dispel or suspend.
So, yes, duration is entirely relevant.
The entry goes on to detail why it functions this way, to paraphrase though: the effect that animates the dead is instantaneously brought into being by magic, but is not continuously sustained by magic afterwards. Therefore, skeletons can enter an antimagic field at their leisure and hack you to bits.
Of note: Danse macabre has a duration on the spell and therefore you could dispel one of the animated creatures.
Just for fun, if dispel magic worked in this way it would be the most powerful spell in the game and here is why:
Anyone that has ever been the target of a cure wounds (or for that matter revivify, raise dead, reincarnation, resurrection, etc.) spell could potentially die outright if targeted by dispel magic since it would erase all previous curative effects in an instant.