You can set the hours / minutes with the functions addMintes() and addHours(), see: https://docs.mendix.com/refguide/add-date-function-calls
So you could use something like this:
addMinutes(addHours(trimToDays($datetime/attribute), x), x)
Also, check out this post where similiar answers were offered: https://forum.mendix.com/link/questions/568