"Give me the knife!"
Translation:Gib mir das Messer!
The dative part is "to me", i.e. mir. The knife is the direct object (what is being given) and hence needs accusative case.
So for it to be dem messer you woukd be saying "give the knife to me" would this change mir to mich?
For the knife to become dative, it would have to be the direct object in the sentence. I can't think of many sensical sentences, but here's an example:
Ich gebe dem Messer eine Tomate.
The knife is dative in this sentence because it is the one receiving the object.
Subject- Ich Verb- gebe Indirect object- dem Messer Direct object- eine Tomate
If you want to learn more about how to determine word order, I recommend going here: https://www.germanwithantrim.com/single-post/2016/1/15/German-Word-Order-Direct-Indirect-Objects