Thanks for the reply Nic,
I took some time before someone responded, so I had actually abandoned the approach and settled with the standard datepart function.
Thanks to your response, I looked at the problem again and have now solved the problem. I still have to input the date in the format yyyy-mm-dd :
set @startdate =CAST('2005-01-27' as smalldatetime)
but if I include a statement :
set dateformat mdy
(default american date input/output), the code from Chris Hedgate now works.
The devil is apparently still in the details and the several datetime formats.
Thank you very much.
John Valore