I'd like to create a Google Apps Script that changes the format of all dates in a sheet based on the year.
- If the date is in the current year, the format should be, e.g.,
Aug 5 - If it's in an earlier or later year, the format should be, e.g.,
3/5/2025
After some research, I'm realizing I want to make sure that I'm not changing any underlying data (e.g., by using Utilities.formatDate) and instead just formatting the cells with dates in them (which I've read that setNumberFormat is the way to do that). There are also cells with simple numbers in them (12, 25, etc) that I don't want to touch.
I've tried using Chat GPT to generate this many times without success.