In October 1863, as Americans by the thousands were suffering and dying in a civil war that had been raging for more than two years and would grind on for almost two more, President Abraham Lincoln issued a proclamation designating “the last Thursday of November next as a day of thanksgiving and praise to our beneficent Father who dwelleth in the heavens.” That was the beginning of Thanksgiving as we know it — an annual national holiday celebrated by Americans each November.

It is hard to imagine a proclamation like Lincoln’s being treated in today’s political environment as anything but a blunder. A president who addressed Americans in the midst of a national cataclysm, urging them, in effect, to look on the bright side would be pilloried for his callousness. But Lincoln was anything but insensitive. He struggled with bouts of deep melancholy and had buried two of his sons, the second just 20 months earlier. Few Americans needed less instruction than Lincoln in the reasons life affords for sorrow.

“The year that is drawing toward its close has been filled with the blessings of fruitful fields and healthful skies,” he began. Acknowledging that the war was taking a severe toll, he stressed nevertheless that “harmony has prevailed everywhere, except in the theater of military conflict.” The nation’s military costs were enormous, yet so was the growth of America’s agriculture, manufacturing, mining, commerce, and population.

These blessings, Lincoln said, were “the gracious gifts of the Most High God, who, while dealing with us in anger for our sins, hath nevertheless remembered mercy.” He called on Americans to give thanks amid their wartime miseries and not wait for the conflict to end.

That message was one that would have resonated with the Pilgrims more than two centuries earlier.

When they gathered in the fall of 1621 to celebrate their first harvest since arriving in the New World the previous winter, they had just come through what, for most of them, must have been the worst year of their lives. So many things had gone wrong. On the Mayflower there had been only 102 passengers and half were already dead. Heavy weather had blown the ship hundreds of miles north of its planned destination and the colonists were unprepared for the harsh climate of Massachusetts in December. They lacked housing, food, supplies. The trauma of having to dig grave after grave in the frozen soil must have been devastating. After burying so many of those they loved, how could the survivors have felt like giving thanks?

The answer is that for the Pilgrims, gratitude wasn’t contingent on feeling. It was an obligation. They gave thanks multiple times daily — in their daily prayers, when they ate, while they worked. On good days and bad, in sickness and in health, they trained themselves to be grateful.

Today there are innumerable studies demonstrating that people who regularly give thanks experience greater levels of happiness, suffer less from depression, are more empathetic and less prone to anger. But long before the advent of modern neuroscience and psychology, the Hebrew Bible, in which the Pilgrims had a passionate and absorbing interest, emphasized that gratitude is the quintessential virtue in shaping good character and healthy societies.

When individuals are reeling from a setback or struggling with loss, when they are gripped by illness or pain, they don’t typically respond with a spontaneous upwelling of thankfulness. It goes against the grain to regard misfortune without resentment. Hence the importance of practicing gratitude, of honing it until it becomes instinctive.

That is something I’ve understood intellectually all my adult life. Yet I still wasn’t prepared for the reality of these last months, when I found myself unable to do things I had always been able to do and there seemed to be no medical explanation for my sudden decline.

There may never be a good medical explanation. I may never find a fix for whatever underlying genetic or chemical flaw caused this illness. But I can try to fix the flaws in my own character that these losses made me more aware of. I can focus less on what is gone and more on appreciating the blessings I still have. I can cultivate equanimity and gratitude.

And the only way to do that, I know, is to work at it. That takes time — which, sooner or later, runs out for each of us.

So I begin each day with the words I was taught to say as a child: Modeh Ani — I give thanks for the gift of another day. Another day in which to work on being a little kinder, a little more patient, a little more grateful. I murmur those words in bed before doing anything else, before I know what the day will bring. As the Pilgrims knew, as Lincoln knew, gratitude is not something to be reserved for days when nothing goes wrong. Giving thanks, like every good character trait, takes practice. But the reward is worth the effort.