How can I differ between last day of a month and first day of the next month?
I don't understand the problem.
If the dates are different, they are different.
Please explain what your problem is.