select * from visiting_timings where ( '22:44:49' BETWEEN fromtime AND totime OR ( '22:44:49' > fromtime && nextday = 1) ) and id='1' Tervetuloa Iltreno -->
09:00 02:00