I have in my SQL Server a DateTime2 Field which represents how long a task took to be completed.
In a simple way, the value is StartDateTimeOfTask - GetDate(), that gives me the result in seconds, and it would be stored like this: 1900-01-01 00:00:05.0966667 --> the task took 5 seconds to complete.
I've tried to store in my ES 7.7 this data ( as DateTime or Integer) so I could sum the time by task, tried to format as Duration and Number 00:00:00, but without success
I don't know how SQL Server work but I can't understand why StartDateTimeOfTask - GetDate() will give you back a date instead of the difference in millis between the end date and the start date.
Having this as a simple integer it will be much easier to store in ES and do all the calculations you need.
Could you try to convert StartDateTimeOfTask and GetDate() to UTCmillis?
Is something like this available in SQL Server: DATEDIFF(MILLISECOND, begin, end)? this should return an integer value of milliseconds elapsed from the begin to the end
For the purpose of displaying document per document, it works perfectly, but I cannot Sum this scripted field, because is now a date type. Is there a way to create a sum to visualize this number as hh:mm:ss.SSSS?
Otherwise I have the sum of thousands of milliseconds, like this:
this sum represents 1 minutes - 6 seconds - 814 milliseconds
Hi, you don't need to use a scripted field for that, you can just specify the format as Number and use the following NumberJS to format as time 00:00:00
This will keep your field as number to allow all the numeric aggregation you need, but you are then formatting the number as a time
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.