More general getDateTime function