New User-Defined Functions in Elliott DDF

New User-Defined Functions in Elliott DDF

Release Date: 12/6/17
Modified Date: 07/08/2024
Version: 8.5 & up

In the future DDF (target to be released with Elliott 8.5,), we will add the following four user-defined functions:
  • ELIDATE2SQL
  • SQLDATE2ELI
  • ELITIME2SQL
  • SQLTIME2ELI
For example, you can use the following SELECT statement:
                select order_no, ELIDATE2SQL(order_date) from cpordhdr;
The date return in the above sample statement will be in the native SQL date format, instead of the Elliott 8-digit date.

The following is the detail of the script that we use to create these four user-defined functions:

CREATE FUNCTION ELIDATE2SQL(:ELIDATE NUMERIC(8,0))
RETURNS DATE
AS 
BEGIN
DECLARE :C CHAR(8);
DECLARE :D DATE;
IF (:ELIDATE = 0) THEN
  SET :D=NULL;
ELSE
  SET :C=CONVERT(:ELIDATE,SQL_CHAR);
  SET :D=CONVERT(concat(concat(concat(concat(left(:C,4),'-'),substring(:C,5,2)),'-'),right(:C,2)),SQL_DATE);
END IF;
RETURN :D;
END;
 
CREATE FUNCTION SQLDATE2ELI(:SQLDATE DATE)
RETURNS NUMERIC(8,0)
AS 
BEGIN
DECLARE :C CHAR(10);
DECLARE :Y NUMERIC(4,0);
DECLARE :M NUMERIC(2,0);
DECLARE :D NUMERIC(2,0);
DECLARE :N NUMERIC(8,0);
IF (:SQLDATE = NULL) THEN
  SET :N=0
ELSE
  SET :C=CONVERT(:SQLDATE,SQL_CHAR);
  SET :Y=CONVERT(LEFT(:C,4),SQL_NUMERIC);
  SET :M=CONVERT(SUBSTRING(:C,6,2),SQL_NUMERIC);
  SET :D=CONVERT(RIGHT(:C,2),SQL_NUMERIC);
  SET :N=:Y * 10000 + :M * 100 + :D;
END IF;
RETURN :N;
END;
 
CREATE FUNCTION ELITIME2SQL(:ELITIME NUMERIC(6,0))
RETURNS TIME
AS 
BEGIN
DECLARE :C VARCHAR(12);
DECLARE :T TIME;
SET :C=CONVERT(:ELITIME,SQL_CHAR);
-- PAD ZEROES ON THE LEFT
SET :C=RIGHT(CONCAT('000000',:C),6);
SET :T=CONVERT(concat(concat(concat(concat(left(:C,2),':'),substring(:C,3,2)),':'),right(:C,2)),SQL_TIME);
RETURN :T;
END;
 
CREATE FUNCTION SQLTIME2ELI(:SQLTIME TIME)
RETURNS NUMERIC(6,0)
AS
BEGIN
DECLARE :C CHAR(8);
DECLARE :H NUMERIC(2,0);
DECLARE :M NUMERIC(2,0);
DECLARE :S NUMERIC(2,0);
DECLARE :N NUMERIC(6,0);
IF (:SQLTIME=NULL) THEN
  SET :N=0;
ELSE
  SET :C=CONVERT(:SQLTIME,SQL_CHAR);
  SET :H=CONVERT(LEFT(:C,2),SQL_NUMERIC);
  SET :M=CONVERT(SUBSTRING(:C,4,2),SQL_NUMERIC);
  SET :S=CONVERT(RIGHT(:C,2),SQL_NUMERIC);
  SET :N=:H * 10000 + :M * 100 + :S;
END IF;
RETURN :N;
END; 

Please also reference the following related KB article:

EMK


    • Related Articles

    • Developing a New Elliott V8.6 Report Desk User Defined Report (UDR)

      'Release Date: 6/20/2018 Version: 8.6 & up This document is written for licensed Elliott Software developers. It is not relevant for regular Elliott users. Overview With proper licensing, Elliott developers can follow these three steps to create a ...
    • Report Desk: User-Defined Formulas

      Release Date: 1/16/2024 Versions: Elliott V8.6 and Above Background Prior to this release, users had the ability to create a user-defined formula by dragging the [New Formula] node on the TreeView in the report designer to a line on the report. That ...
    • Elliott V7.1 Release Notes: What's New Since Elliott V7.0

      What’s New Since Elliott V7.0 System Wide Features eContact Manager After V7.1, an eContact can be set up even if you don’t have a contact’s email address. The eContact database has been expanded to include Company Name, Birthday, Created By and ...
    • Login SUPERVISOR to Update DDF Files After Elliott 8.6 Installation

      Release Date: 8/17/2022 Version: Elliott V8.6 and Higher Background Most of Elliott Business Software uses the PSQL transactional database engine (Btrieve) to perform its work. However, some new features of Elliott V8.6 use the PSQL relational ...
    • Elliott V7.3 Release Notes: What's New Since Elliott V7.2

      What’s New Since Elliott V7.2 Customer Relationship Management (CRM) CRM and beyond The center of Elliott’s Customer Relationship Management is eContact. eContact is an extension to the Customer database, as well as Vendor, Employee, Salesman, Sales ...