Last active
March 30, 2019 17:24
-
-
Save ralfbecher/3dd6fa134eefacb18f40 to your computer and use it in GitHub Desktop.
JavaScript function to create a Date from QlikView or Qlik Sense numerical Date value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dateFromQlikNumber(n) { | |
var d = new Date(Math.round((n - 25569) * 86400000)); | |
// since date was created in UTC shift it to the local timezone | |
d.setTime(d.getTime() + d.getTimezoneOffset() * 60000); | |
return d; | |
} |
Hi Ralf, looks like you've got an error on line 2, one extra parentheses. Should be:
var d = new Date(Math.round((n - 25569) * 86400000));
You have an extra (
after Date.
Thanks for this awesome script!
Thanks Speros for pointing this out! Wonder how that came in..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I added rounding to avoid inaccuracy caused by Qlik's float numbers..