Someone else had a similar request, to record the maximum daily outdoor temperature (can be any numeric parameter). In addition, they wanted to know the maximum weekly/monthly/yearly temperature.
The suggested solution was similar to what mekaneck proposed above (use a Trigger-based Template Sensor to report the maximum temperature), and then uses the Utility Meter integration to report long-term daily/weekly/monthly/yearly statistics (i.e. these values are stored in a table in the database that isn’t periodically purged).
The main difference between mekaneck’s example and the one in the following link is that (due to different requirements) it resets at the start of every day and records the time when the temperature value was updated. It’s the sensors created by the Utility Meter integration that are responsible for recording long-term daily/weekly/monthly/yearly statistics.