Am creating a stored proc to copy data into a reporting table.
The date I run the stored proc could change each month. It could be a few days prior to month end, or a few days after month end, but I want the date inserted to be that of the month end.
So, lets say I allow the stored proc to be run 10 days prior to 5 days after month end. For example, if the script is run between 22 March 2023 and 5 April 2023 I want the date inserted to be 31 March 2023
How do I write this in a select statement that I can include in my stored proc?