First commit with new select_duration feature. Support to be added for postgres and mysql