Skip to main content

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
Action-Packed Learning Awaits! QlikWorld 2023. April 17 - 20 in Las Vegas: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
danelooman
Creator
Creator

DateTime to Num rounding error

In JS I am taking in strings like "2020-09-16 08:26:02" and converting them to numbers like "44090.35141203704" 

I am using the function below and on about 25% of my attempts I am getting a rounding error. Has anyone encountered this or done something like this in a mashup/viz before? 

let item = "2020-09-16 08:26:02" 
let parts = item.split(/[?:,| -]+/) 
let date = new Date(parts[0], parts[1]-1, parts[2], parts[3], parts[4], parts[5])
let returnDateTime = 25569.0 + (date.getTime() - date.getTimezoneOffset() * 60 * 1000) / (1000 * 60 * 60 * 24);
return returnDateTime;

 

0 Replies