Sql sensor get yesterday kl 23:00:00

I have a sql sensor, works fine.
But how do I make it get yesterday at 23 instead

 datetime(yesterday  23:00:00')
- platform: sql
    queries:
      - name: Kl_23 
        query: "SELECT * FROM states WHERE entity_id = 'sensor.energi_data_service' AND last_updated <= datetime('2022-11-27 23:00:00') ORDER BY last_updated DESC LIMIT 1;"
        column: 'state'

DATE_ADD(DATE_SUB(CURDATE(), INTERVAL 1 DAY), interval 23 hour)

This takes the current date (not time) and subtracts 1 day, then adds 23 hours to get 23:00 last night. You might also want to check whether you should be using local time or UTC. My hassos uses UTC (not sure if it’s always UTC or using system config), so I would use UTC_DATE() instead of CURDATE().