Commit f38a3782 authored by Carsten  Rose's avatar Carsten Rose
Browse files

New stored procedure: QDATE_FORMAT(timestamp). Return text in dd.mm.yyyy hh:mm...

New stored procedure: QDATE_FORMAT(timestamp). Return text in dd.mm.yyyy hh:mm format or '-' is timestamp is empty.
parent 8d6660ea
Pipeline #2578 passed with stages
in 2 minutes and 52 seconds
......@@ -6862,8 +6862,8 @@ Example::
.. _special-sql-functions:
Special SQL Functions
---------------------
Special SQL Functions (prepared statements)
-------------------------------------------
.. _qbar-qscape-qfq-delimiter:
......@@ -6925,6 +6925,21 @@ Output::
hello world-
.. _qdate_format:
QDATE_FORMAT: format a timestamp, show '-' if empty
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The SQL function QDATE_FORMAT(timestamp) returns 'dd.mm.YYYY hh:mm', if 'timestamp' is 0 returns '-'
Example::
10.sql = SELECT QDATE_FORMAT( '2019-12-31 23:55:41' ), ' / ', QDATE_FORMAT( 0 ), ' / ', QDATE_FORMAT( '' )
Output::
31.12.2019 23:55 / - / -
.. _strip_tags:
strip_tags: strip html tags
......
......@@ -102,4 +102,20 @@ BEGIN
IF (!end) THEN SET end = start; END IF;
SET str = INSERT(str, start, end - start + 1, "");
END LOOP;
END;
\ No newline at end of file
END;
###
#
# QDATE_FORMAT(timestamp)
#
DROP FUNCTION IF EXISTS QDATE_FORMAT;
CREATE FUNCTION `QDATE_FORMAT`(ts DATETIME)
RETURNS TEXT
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
DECLARE output TEXT;
SET output = IF(ts = 0, '-', DATE_FORMAT(ts, "%d.%m.%Y %H:%i"));
RETURN output;
END;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment