fix for issue 320: no output when max_cdate is used for dataset API. Fix...

@giffels:
please review and merge this patch.
Thanks,
Yuyi