Create a query to obtain a user's average between two dates

Hello everyone,

I'm looking to create a rule that will allow me to obtain the average of a date between two dates. For example, a user usually generates logs between 8am and 6pm.

I've tried an approach with ES|QL but I'm stuck.