sql - get all dates between multiple date range from mysql table -
sql - get all dates between multiple date range from mysql table -
this my mysql table:
name leavetype -------------------------------------------------- ravi 2015-01-01 201-01-02 casual leave sudha 2015-01-02 201-01-02 sick leave
expected output
2015-01-01 ----------- 1. ravi cl 2015-01-02 ------------- 1. ravi cl 2. sudha sl
this mysql query:
select leave_id, emp_id, employee_id, name, `from`, `to` emp_leave hod_id='42' , from` between '2015-4-01' , '2015-04-10' , `to` between '2015-4-01' , '2015-04-10' order `from`
your to
dates have wrong year. have 201-01-02
instead of 2015-01-02
. 1 time that's fixed, , query changed have right dates , prepare syntax error, it works fine.
if it's still not working, it's possible whatever hod_id
isn't 42
.
be careful date formatting. many systems take single digit months 2015-4-20
, not a proper iso 8601 date. month should have 2 digits, 2015-04-20
.
mysql sql date
Comments
Post a Comment