JavaScript Datum in Qlik Format umrechnen

Mit der folgen Funktion kann man ein JavaScript Date() in das Qlik Sense / View Format konvertieren:


function Date2QlikDate(aDate){
var nDate = new Date(aDate); 
var nMonth = nDate.getUTCMonth() +1; 
var nDay = nDate.getUTCDate() +1;
var nYear = nDate.getUTCFullYear();
// DMY to Modified Julian calculated with an extra subtraction of 2415019 - 153 for Q.
var nSerialDate =
parseInt(( 1461 * ( nYear + 4800 + parseInt(( nMonth - 14 ) / 12) ) ) / 4) +
parseInt(( 367 * ( nMonth - 2 - 12 * ( ( nMonth - 14 ) / 12 ) ) ) / 12) -
parseInt(( 3 * ( parseInt(( nYear + 4900 + parseInt(( nMonth - 14 ) / 12) ) / 100) ) ) / 4) +
nDay - 2415019 - 32075 - 153;

if (nSerialDate < 60) {
// Because of the 29-02-1900 bug, any serial date
nSerialDate--;
}
return nSerialDate;
}
Share
Thomas Lindackers
Senior Technical Trainer @ Qlik
04.2017 - Heute
Thomas Lindackers
Senior Technical Trainer
04.2017 - heute
Thomas Lindackers
Technical Trainer @ Qlik
10.2014 - 04.2017
Thomas Lindackers
Technical Trainer
10.2014 - 04.2017
Thomas Lindackers
Tech. Support Engineer @ Qlik
07.2012 - 10.2014
Thomas Lindackers
Technical Support Engineer
07.2012 - 10.2014
Thomas Lindackers
Service Desk Analyst @ Qlik
10.2010 - 07.2012
Thomas Lindackers
Service Desk Analyst
10.2010 - 07.2012
alias Linse
Bloghoster / Entwickler / Fotograf
Thomas Lindackers
Senior Technical Trainer
Slider