0

I have the following query which works fine, but when I try to concatenate the finishing hour of the reservation, it doesn't work anymore. I'm sure it's a type but I can't find it:

SELECT RESERVATIONID, USERID, CLASSNAME, GRADENAME, date_format(RESERVATIONDUEDATE, '%e - %M - %Y, %l:%i %p') + ' - ' + date_format(RESERVATIONEXPIREDATE, '%l:%i %p') resduedate
FROM reservation join class on
reservation.CLASSID = class.CLASSID
join grade on
reservation.GRADEID = grade.GRADEID
WHERE USERID =  'xxx'
AND RESERVATIONDUEDATE > CURDATE() 

The output for that column is 32 when it should be the complete date plus the time.

Any ideas as to what might be wrong?

CodeTrooper
  • 1,890
  • 6
  • 32
  • 54
  • Use `concat(expr1,' - ', expr2)` function – M Khalid Junaid Aug 27 '14 at 16:03
  • Solved. This method I use used to work on microsoft sql server. Does this mena that `+` cannot be used to concatenate here? Make sure you put this as an answer so I can check you. – CodeTrooper Aug 27 '14 at 16:04
  • That's correct. `+` is not standard SQL. You can use `||` instead of `+`, but that depends on your MySQL server being configured in a specific way: http://stackoverflow.com/questions/8212192/can-mysql-concatenate-strings-with It's better to just stick with `CONCAT`. – Jordan Running Aug 27 '14 at 16:06

0 Answers0