In the episode titled "27 and Still Cooking" (S7E18), Cliff spends the episode attempting to recreate Calliloo Pot, a restaurant they went to on their honeymoon twenty-seven years prior. So by season seven, they were married twenty-seven years.
Cliff turned 48 in the first season, so you could logically surmise that he was roughly 54 years old by their 27th wedding anniversary (though per @Kevin's solid point above-- the Cosby Show universe doesn't necessarily apply logic at all times)-- so Cliff was about 27 when they were married.
Clair turned 46 in the fifth season, making her (at best guess) 48 for their anniversary in the aforementioned episode, so Clair was about 21 when they were married.
The confusing part of this answer enters the conversation upon review of the fourth season episode titled "The Locker Room," wherein we learn that Clair is four years younger that Cliff.
Mystery and answers aside, I concede this does not answer your specific question: how long did Cliff and Clair date? But it does illuminate just how messy the Cosby Show continuity is (while sort of answering your question).
- Cliff informs Denise that his reason for attending Hillman College was to follow a girl there, who he reveals to be Clair in S1E6 "Breaking With Tradition."
- In S4E23 "The Prom," we learn that Clair never went to her prom because Cliff was taking final exams in his junior year at Hillman.
Sources: List of Cosby Show Episodes, List of Cosby Show Characters