From aa44ce6e9703ab15bb5270251358fb756a347f17 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 5 Jun 2013 18:54:26 +0200 Subject: Add optional argument to now() for simple interval calculations on SQL-side --- program/lib/Roundcube/rcube_db_mssql.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'program/lib/Roundcube/rcube_db_mssql.php') diff --git a/program/lib/Roundcube/rcube_db_mssql.php b/program/lib/Roundcube/rcube_db_mssql.php index 37a42678a..71317078c 100644 --- a/program/lib/Roundcube/rcube_db_mssql.php +++ b/program/lib/Roundcube/rcube_db_mssql.php @@ -48,19 +48,23 @@ class rcube_db_mssql extends rcube_db /** * Return SQL function for current time and date * + * @param int $interval Optional interval (in seconds) to add/subtract + * * @return string SQL function to use in query */ - public function now() + public function now($interval = 0) { + if ($interval) { + $interval = intval($interval); + return "dateadd(second, $interval, getdate())"; + } + return "getdate()"; } /** * Return SQL statement to convert a field value into a unix timestamp * - * This method is deprecated and should not be used anymore due to limitations - * of timestamp functions in Mysql (year 2038 problem) - * * @param string $field Field name * * @return string SQL statement to use in query -- cgit v1.2.3