This is a matter of ancient vs modern idioms and a rather contentious matter depends upon it. Let me illustrate.
In both English and Hebrew the word "day" is used in two distinct senses:
- describing a literal 24 hour period, eg, "five days ago ...", or, "on the third day ...", etc. See Gen 1:8, 13, etc.
- a general; undefined period such as "In my parents day ...", or, "in the olden days", etc. See Gen 4:3, 5:4, etc.
The two forms are easy to distinguish - the first always has a numeral and the second does not.
Gen 2:17 בְּי֛וֹם
In Gen 2:17, the word בְּי֛וֹם = "in/on the day". This is the very literal translation. However, modern versions recognize that this might leave the impression that God was predicting that Adam and Eve would die on the same day that they ate the forbidden fruit. However, this is NOT what the text is saying.
The text is simply saying that when Adam and Eve sinned by eating the forbidden fruit, they would begin the process of dying. Thus, it does NOT say that they would die the same day.
Hence some modern translations translate more sensitively and idiomatically and say, "when you eat", or similar.