SELECT substr(`DATEVAL`,1,10) as Date, substr(`DATEVAL`, 12,8) as Time, `NAME` as Name, `PHONENUMBER` as Phone , `ADDRESS` as Address , `TEMPERATURE` as Temperature FROM `visitorsregister` WHERE TIME_STAMP >= str_to_date('$toDateTime','%Y-%m-%d %H:%i:%s') AND TIME_STAMP <= str_to_date('$fromDateTime','%Y-%m-%d %H:%i:%s')