Skip to content

Instantly share code, notes, and snippets.

View torrobinson's full-sized avatar
🟣

Tor torrobinson

🟣
View GitHub Profile
@torrobinson
torrobinson / linq.js
Created October 28, 2020 13:43
LINQ-esque javascript array estentions
Array.prototype.where = function (condition) {
return this.filter(condition);
};
Array.prototype.select = function (attributes) {
return this.map(attributes);
};
Array.prototype.sum = function () {
return this.reduce((a, b) => a + b, 0);
};
Array.prototype.average = function () {
@torrobinson
torrobinson / dates.sql
Last active September 24, 2021 16:57
DB2 JDE Date Helpers
-- Getting Gregorian Date from Julian Column:
CASE WHEN [JULIAN] IS NULL OR [JULIAN] = 0 THEN '' ELSE CAST(CAST(CAST(((CAST(([JULIAN]-MOD([JULIAN],1000))/1000 AS INT)+1900)*1000)+MOD([JULIAN],1000) AS CHAR(7)) AS DATE) AS CHAR(10)) END
-- Getting Time from 6-digit time (130045 = 1:00:45pm)
CAST(SUBSTR([TIMESTR],1,2) || ':' || SUBSTR([TIMESTR],3,2) || ':' || SUBSTR([TIMESTR],5,2) as TIME)
-- Current Date in JDE Julian Format:
select (YEAR(NOW()) - 1900) || LPAD(DAYOFYEAR(NOW()),3,'0') from sysibm.sysdummy1;
--or
select (100000+(YEAR(curdate())-2000)*1000+dayofyear(curdate())) from sysibm.sysdummy1;