in reply to Close a file and reopen a new one at midnight


Two things after a glace at your code;

You may want to buffer the end of the day, which may give you a more accurate end-of-day and start-of-day.

Good Luck!

"Well done is better than well said." - Benjamin Franklin