From 9649b73a0ce805d729a3b8c6b2d53f74aaa07b94 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 1 Nov 2022 14:04:02 +0000 Subject: [PATCH] APIv4 - Add DATEDIFF to calculate days between two dates Co-authored-by: colemanw --- Civi/Api4/Query/SqlFunctionDATEDIFF.php | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Civi/Api4/Query/SqlFunctionDATEDIFF.php diff --git a/Civi/Api4/Query/SqlFunctionDATEDIFF.php b/Civi/Api4/Query/SqlFunctionDATEDIFF.php new file mode 100644 index 0000000000..cc5a6862a5 --- /dev/null +++ b/Civi/Api4/Query/SqlFunctionDATEDIFF.php @@ -0,0 +1,48 @@ + 2, + 'min_expr' => 2, + 'optional' => FALSE, + 'label' => ts('diff'), + ], + ]; + } + + /** + * @return string + */ + public static function getTitle(): string { + return ts('Days between two dates'); + } + + /** + * @return string + */ + public static function getDescription(): string { + return ts('Number of days between two dates.'); + } + +} -- 2.25.1