github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/function/func_datetime_datediff.result (about)

     1  SELECT DATEDIFF('2017-08-17','2017-08-17');
     2  datediff(2017-08-17, 2017-08-17)
     3  0
     4  SELECT DATEDIFF('2017-08-17','2017-08-08');
     5  datediff(2017-08-17, 2017-08-08)
     6  9
     7  SELECT DATEDIFF('2017-08-08','2017-08-17');
     8  datediff(2017-08-08, 2017-08-17)
     9  -9
    10  SELECT DATEDIFF(NULL,'2017-08-17');
    11  datediff(null, 2017-08-17)
    12  null
    13  SELECT DATEDIFF('2017-08-17',NULL);
    14  datediff(2017-08-17, null)
    15  null
    16  SELECT DATEDIFF(NULL, NULL);
    17  datediff(null, null)
    18  null
    19  drop table if exists t1;
    20  create table t1(a INT,  b date);
    21  insert into t1 values(1, "2012-10-11");
    22  insert into t1 values(2, "2004-04-24");
    23  insert into t1 values(3, "2008-12-04");
    24  insert into t1 values(4, "2012-03-23");
    25  insert into t1 values(5, "2000-03-23");
    26  insert into t1 values(6, "2030-03-23");
    27  insert into t1 values(7, "2040-03-23");
    28  SELECT a, DATEDIFF('2022-10-9', b) from t1;
    29  a    datediff(2022-10-9, b)
    30  1    3650
    31  2    6742
    32  3    5057
    33  4    3852
    34  5    8235
    35  6    -2722
    36  7    -6375
    37  drop table t1;
    38  drop table if exists t1;
    39  create table t1(a INT,  b date);
    40  insert into t1 values(1, "2012-10-11");
    41  insert into t1 values(2, "2004-04-24");
    42  insert into t1 values(3, "2008-12-04");
    43  insert into t1 values(4, "2012-03-23");
    44  insert into t1 values(5, "2000-03-23");
    45  insert into t1 values(6, "2030-03-23");
    46  insert into t1 values(7, "2040-03-23");
    47  SELECT a, DATEDIFF(b, '2022-10-9') from t1;
    48  a    datediff(b, 2022-10-9)
    49  1    -3650
    50  2    -6742
    51  3    -5057
    52  4    -3852
    53  5    -8235
    54  6    2722
    55  7    6375
    56  drop table t1;
    57  drop table if exists t1;
    58  create table t1(a date,  b date);
    59  insert into t1 values('2022-10-9', "2012-10-11");
    60  insert into t1 values('2022-10-9', "2004-04-24");
    61  insert into t1 values('2022-10-9', "2008-12-04");
    62  insert into t1 values('2022-10-9', "2012-03-23");
    63  insert into t1 values('2022-10-9', "2000-03-23");
    64  insert into t1 values('2022-10-9', "2030-03-23");
    65  insert into t1 values('2022-10-9', "2040-03-23");
    66  SELECT a, b, DATEDIFF(a, b) from t1;
    67  a    b    datediff(a, b)
    68  2022-10-09    2012-10-11    3650
    69  2022-10-09    2004-04-24    6742
    70  2022-10-09    2008-12-04    5057
    71  2022-10-09    2012-03-23    3852
    72  2022-10-09    2000-03-23    8235
    73  2022-10-09    2030-03-23    -2722
    74  2022-10-09    2040-03-23    -6375
    75  drop table t1;