How to calculate difference between two dates in months in MySQL

前端 未结 7 1594
眼角桃花
眼角桃花 2020-12-13 15:58

I have two columns in a MySQL table:

  • DateOfService (datetime)
  • BirthDate (date)

I want to run a MySQL query that will provide date diffe

相关标签:
7条回答
  • 2020-12-13 17:04

    TRY with

    PERIOD_DIFF(P1,P2)

    Returns the number of months between periods P1 and P2. P1 and P2 should be in the format YYMM or YYYYMM. Note that the period arguments P1 and P2 are not date values.

    mysql> SELECT PERIOD_DIFF(200802,200703); -> 11

    0 讨论(0)
提交回复
热议问题