Exchanging pleasantries is merely an acknowledgement of another person's presence in your space.
When approaching a coworker in the corridor of your office, you might say, "Hi. How are you?"
This is not an invitation for conversation. The clue for this being that neither of you stopped. In fact, as he passed you, your coworker threw back a "Great! How are you?"
And his reply signaled the end of your exchange.
The workplace can be a busy environment. If you approach someone you need to have a conversation with, instead of the usual, "Hi. How are you?" simply ask, "Hi, Debbie. Do you have a moment to discuss the Halfacre account? I have a question about the contract."
Debbie will either stop and discuss it with you then, will ask to meet you in her office, or will suggest another time for your discussion.
However, if the "Hi. How are you?" comes at you as someone is stopping, that is a silent signal to stop and chat for a moment. Even if you don't have the time, show courtesy by exchanging pleasantries at a full stop rather than in passing.
When out and about around your office, you're likely to see the same people several times during the day.
Do you exchange pleasantries each and every time? Not necessarily.
After the initial exchange, as in the examples above, you might just smile and give a nod the next time you pass the same person. This simple gesture acknowledges people without repeating the same rote dialogue.
You might try to make someone smile with a funny comment or quick joke that you can share as you pass.
The art of exchanging pleasantries is not difficult. Like most courtesies, it only requires that you be mindful of the people and situations around you.
But this simple acknowledgement of another person's presence in your vicinity makes that person feel special. And you will leave an impression of being a kind, courteous individual.
It is this building of good will that makes any work, or social, environment a better place to be!