mariaDB
마리아 db datediff 날짜차이
xemaker
2022. 4. 1. 11:16
날짜 차이를 알려주는 마리아 db datediff 함수가 있다.
순서가 좀 헷갈리는데 잘 봐야 한다.
일단 큰 값이 앞에오면 된다.
selelct datediff('2022-01-01',now());
하면 -90 이 나온다.
selelct datediff(now(),'2022-01-01');
하면 90 이 나온다.
하이디 SQL에서 보면 F1 클릭해서 DATEDIFF 설명을 보면
Syntax
-----------
DATEDIFF(expr1,expr2)
Description
------------
DATEDIFF() returns (expr1-expr2) exressed as a value in days from on date to the other. expr1 and expr2 are date of date-and time expressions. Only the date parts of the values are used in the calculation.