Thanks Mike for your (ever) speedy reply - don't you have a home to go to?.
I get an invalid function count type error.
On reflection, DATE(2999,12,31)-visitdate gives a number of days, which DTOS can't handle. Nevertheless, you've woken my brain up and sparked new ideas, which after all is...