After much investigation I come with a solution for both at SQL level as well as node.js level.
To convert 7 digit Julian date into Normal Date using SQL query you can use below query for IBM DB2 iSeries database -
SELECT DATE(((1160920 /10000)+1900)|| '-' ||
(MOD(1160920 ,10000) /100)|| '-' ||
MOD(1160920 ,100))
FROM
SYSIBM.SYSDUMMY1
To perform same conversion using node.js use below code it will convert perfectly
var dateFormat = require('dateformat');
function julianIntToDate(n) {
var yy = ((n/10000)+1900);
var year = Math.floor(yy);
var mm = ((n % 10000)/100);
var mon = Math.floor(mm);
mon = leadingZero(mon);
var dd = (n % 100);
dd = leadingZero(dd);
console.log("Year--"+year);
console.log("Month--"+mon);
console.log("Day--"+dd);
var now = new Date(year+"-"+mon+"-"+dd);
console.log("Converted Date-->"+now);
orderDate = dateFormat(now, "yyyy-mm-dd'T'HH:mm:ss-0500");
return (orderDate);
function leadingZero(value) {
if (value < 10) {
return "0" + value.toString();
}
return value.toString();
}
}
console.log("Julian Date--->"+1160920);
console.log("Normal Date--->"+julianIntToDate(1160920).toString());