php - How to select data between dates where the checkin and checkout field type is in varchar? -


this question has answer here:

i want select data between dates table

for eg:guestrocordtransac(tbl name)

id,roomno,roomtype, checkin,       checkout  1  101      baywatch  05/17/2015 05/24/2015  2  102      baywatch  05/10/2015 05/16/2015 

when tried writing query 1 roomno 101

select roomno guestrocordtransac checkin between "05/14/2015" , "05/29/2015" 

the correct answer fix data date values stored date/times. better use native database types values.

the second best thing (and remote second best) conversion on fly:

select roomno guestrocordtransac str_to_date(checkin, '%m/%d/%y') between '2015-05-14' , '2015-05-29'; 

when using date constants, use iso standard format of yyyy-mm-dd.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -