Hi, Julian,
  When I using TIMESTAMPDIFF, run the sql as follows:

SELECT
 timestampdiff(WEEK, timestamp '2019-06-01 07:01:11',timestamp '2020-06-01
07:01:11'),
 timestampdiff(WEEK, timestamp '2020-06-01 07:01:11',timestamp '2021-06-01
07:01:11')
 FROM depts limit 1;

I get the result : | 52         | 52         |

And I check it in the MSSQL:

SELECT
  datediff(WEEK, '2019-06-01 07:01:11','2020-06-01 07:01:11'),
  datediff(WEEK, '2020-06-01 07:01:11', '2021-06-01 07:01:11')
FROM stu;

I get the result:  |53     |52

As we know if the year starts on a week in a non-leap year, you end up with
53 weeks. Or if either of the first two days lands on a week during a leap
year, then you can also get 53 weeks.

So, I want to know why design `TIMESTAMPDIFF` as above logic. Please tell
me more about it.

Thanks,
SunJincheng

Reply via email to