Skip to main content
Announcements
Qlik Launches Open Lakehouse and advanced agentic AI experience in Qlik Answers! | LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jedgson
Creator

MakeTime function

Hi I am currently using v8.5 and have an issue linking on a time field.

I have a Time table that is created using Load recno() / 86400 autogenerate(86400);

This generated a table with a decimal value for every second in the day.

In another table I am using MakeTime(hField, mField, sField) to generate a decimal time from 3 seperate fields.

The problem is if I take for examlple 1 minute past midnight 00:01:00.

In my Time table this would be 60/86400 = 0.00069444444444444 and in in the second table it would be MakeTime(0,1,0), now when I display this as a number it gives me 0.00069444443215616.

Although this gives me a very, very small difference it means that these two values will not link. I have got around this by converting each field to seconds, adding them together and then dividing by 86400, but would like to know how the maketime() function works as it is tidier?

Jay

3 Replies
hector
Specialist

Hi, did you try avoid the decimals (i mean for the link field), and use the format hhmmss (as an integer number) instead?

try

num#(time(60/86400,'hhmmss'))


in your table 1

AND

num#(time(maketime(0,1,0),'hhmmss'))


in your table 2

Hope it helps

rgds

Oleg_Troyansky
Partner Ambassador/MVP

Function MakeTime() will track time down to a millisecond, so it''s very difficult to link on a Timestamp field. I'd recommend converting the time into a whole number of seconds and linking based on that.

jedgson
Creator
Author

Thanks for the replies - I think I may change my code to use an integer instead of a decimal as suggested.

Oleg, I understand that the MakeTime() function tracks to the millisecond but that still wouldn't explain why I get 2 different values in my example above. What I am trying to find out is how the MakeTime function calculates/stores a time? If you convert the decimal in my example above back to an integer it does not give you exactly 60s

0.00069444443215616 * 86400 = 59.999998938.

Either my calculations are incorrect or the way in which MakeTime calculates the time is wrong!

Jay