The dative case is commonly known as the grammatical case of indirect objects (the secondary object of ditransitive verbs like dar), and it is marked by several features in Spanish: special pronouns (me, te, le, nos, os, les, se), position in the sentence, and the use of "personal a".
The indirect object is an argument of the verb, i.e. it is part of its core syntax. For example, me in «¿Me lo das, por favor?» is a dative pronoun and functions as the required indirect object of the verb dar. This is easy enough; students of Spanish learn this kind of thing together with the verbs (in this case, that dar needs three arguments: a subject, a direct object and an indirect object).
In this answer I will not be talking about that. Rather, my focus will be on the dative when used as an adjunct.
Explanation and examples come from the Nueva Gramática de la Lengua Española (NGLE).
Dative of interest
The dative of interest (NGLE 35.7b) marks a person or thing that is benefitted, harmed, or generally affected by the action or process. It corresponds to the dativus commodi or dativus incommodi of classical Latin. It can sometimes be difficult to distinguish from the garden variety indirect object. One indication that you're looking at a dative of interest is that it can often be replaced with para or por (the dative of interest appears in boldface):
- Salúdeme a la familia. = "Say hello to the family (for me).", equivalent to Salude a la familia por mí.
- Nos trabajó todo el día. = "He worked (for us) the whole day.", also Trabajó para nosotros todo el día.
- Ella le cocinó un plato especial. = "She cooked a special dish (for him)."
Such a substitution will be more or less natural, depending on the register, dialect and exact expression.
The ethical dative is a dative that shows a certain interest, concern or involvement. It sometimes overlaps with the sympathetic dative (see below). For example (based on NGLE 35.7r, with the dative pronoun in bold):
- El bebé no me duerme. "The baby doesn't sleep."
- Las plantas siempre se te mueren. "Plants always die."
- Se les puso nerviosa. "She got nervous."
You'll notice that in these three examples, I've refrained from translating the ethical dative pronoun. But this little pronoun is actually essential to get the meaning of the sentence. In the first example, the pronoun me refers to the first person singular and the implication is (1) that the baby is the speaker's child, and (2) that it pains the parent that the baby is not sleeping. The latter is the mark of the ethical dative; the former also makes it a sympathetic dative. In English this could be expressed as "The baby won't sleep for me."
In the second example, te indicates that plants always die under your care; in English this could be translated as "Plants always die on you (when you try to care for them)."
In the third example, someone is getting nervous and this is clearly a concern for some specific people (who are referred to by the pronoun les -- the 3rd person plural). Here, the dative suggests that the person who got nervous is under the care or watch of others who have an active interest in her. Perhaps, by getting nervous, there's some concern that she might have let them down. In English this phrase could be expressed as "She got nervous on them."
In each case it would be possible to remove the dative pronoun and keep the basic English translations I've provided. But valuable information would be lost.
The sympathetic dative is widely used in constructions with body parts of other inalienable possessions. It marks an attribution which can be possessive or inclusive (NGLE 35.1e, 35.7f-q). The dative indicates who owns the body part or possession; and the body part or thing possessed must appear with a definite article. For example:
- Me lavo las manos. "I wash my hands."
- Se le cae el pantalón. "His pants are falling down."
- ¿Te duele la cabeza? "Does your head hurt?" (Is your head causing you pain?)
This is a structure that often confuses Spanish learners, since in English and many other languages, body parts and inalienable possessions (such as articles of clothing) are indicated by simple possessive pronouns ("My pencil broke"), whereas in Spanish, we need the sympathetic dative to accomplish the same thing («Se me quebró el lápiz»).
The sympathetic dative works also for simple possession, association and family relationships:
- Se le inundó la casa. "The (=his) house got flooded."
- Se nos casó María. "(Our) María got married."
- Te quedó muy bien el artículo. "The (=your) article turned out well."
In each case there's an implication of association (the house belongs to the third person implied by the pronoun, María is part of the speakers' family, and the article was written by the person being spoken to).
The aspectual dative (NGLE 35.7v) is used for several kinds of emphasis. One particular feature of it is that it always agrees with the subject of the sentence. It therefore looks like a reflexive verb or a regular pronominal verb, but it's not truly reflexive and it differs from the pronominal verbs in that the pronoun is not compulsory. The aspectual dative is often found with verbs that indicate consumption of food and drink, like beber and comer, but also of figurative consumption (of news, of reading):
- Ayer me comí una pizza. "Yesterday I ate a pizza."
- Vamos a tomarnos una cerveza. "Let's go have a beer."
- Se leyó los diarios mientras desayunaba. "He read the newspapers while he had breakfast."
The implication that the dative pronoun adds is that the "consumption" was complete or that it had a definite ending (cf. perfective aspect). The emphasis is often achieved by adding words like todo/a(s) or completo/a(s). In each of the above examples, the aspectual dative indicates that the action (eating a pizza, drinking a beer, reading the newspapers) was finished as expected. There are limits to the use of this dative, related to the semantics of the action it indicates; you cannot say, for example, *«Ayer me comí pizza», because pizza as a mass noun is not bounded and therefore its consumption cannot be marked as "finished".
In some cases the aspectual dative changes the meaning of the verb, which can then be considered to be a pronominal version of the basic form. For example (NGLE 35.7y):
- saber algo = "to know sth.", but saberse algo = "to know sth. by heart"
- creer algo = "to believe sth.", but creerse algo = "to take sth. as true on good faith"
- llevar la plata = "to transport the money", but llevarse la plata = "to take the money away, to run away with the money"
Note how in these examples the verb with the aspectual dative implies a "perfect" (finished) action: saberse algo implies "to have memorized sth."; creerse algo implies "to have come to accept sth. as true"; llevarse la plata implies "to have taken the money without obvious intention of returning".
Addenda: a confusion of datives
This is just something I couldn't resist to add. It's a joke that illustrates the ambiguity of some uses of the dative. The author I don't really know; the one who comments on it is Elena Álvarez Mellado, a computational linguist.
The joke is a command directed at the home personal assistant Alexa, followed by Alexa's reply. It reads:
–Alexa, pídeme una pizza.
–¿Me das una pizza?
This cannot be translated into English. A non-literal translation would be:
–Alexa, order me a pizza.
–¿Can I have a pizza?
The confusion stems from the fact that the dative, used with the verb pedir, admits two meanings: a regular indirect object or a dative of interest (i.e. showing someone for whose benefit an action is intended). Therefore the imperative pídeme una pizza may mean "order me a pizza; order a pizza for me", which is a dative of interest and of course the intended meaning; but it could also mean "ask me for a pizza; ask for a pizza from me". Context and common sense should make this clear, but machines don't have common sense and IAs are still notoriously bad at reading context.