MYSQL Datediff between two dates based on year I have two dates date column like '2017-12-29' and '2018-01-05' the datediff between these dates is 8, but i want to know the datediff which fall on 2018 which should be 5. I'm working on mysql.
Does this work?

CREATE TABLE t1 (
  id int unsigned primary key, 
  date1 date, 
  date2 date
);

INTSERT INTO t1 (id, date1, date2) 
  VALUES (1, '2017-12-29', '2018-01-05');

SELECT id, 
  datediff(date2, date1) "days since date1", 
  datediff(date2, makedate(year(date2),1)) "days since new year" 
FROM t1;
+----+------------------+---------------------+
| id | days since date1 | days since new year |
+----+------------------+---------------------+
|  1 |                7 |                   4 |
+----+------------------+---------------------+