Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JavaScript function to create a Date from QlikView or Qlik Sense numerical Date value
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;
}
@gsbeaton

This comment has been minimized.

Copy link

@gsbeaton gsbeaton commented Apr 26, 2017

Thanks Ralf, this helped me out today.

@ralfbecher

This comment has been minimized.

Copy link
Owner Author

@ralfbecher ralfbecher commented Feb 6, 2018

I added rounding to avoid inaccuracy caused by Qlik's float numbers..

@skokenes

This comment has been minimized.

Copy link

@skokenes skokenes commented Mar 29, 2019

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!

@ralfbecher

This comment has been minimized.

Copy link
Owner Author

@ralfbecher ralfbecher commented Mar 29, 2019

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
You can’t perform that action at this time.