MySQL Stored procedure insert new row on new day/month/year
===

I am currently writing a trigger that calls a stored procedure on each new inserted row in master table, that computes and updates a specific row in auxiliary table. I have a column Date, that holds date and time in this format: **YYYY-MM-DD hh:mm:ss**

Now I have a specific logic in my application, that compares dates from two sequence rows from the master table and if the date is new day (e.g 2012-07-11 00:00:00, date before 2012-07-10 23:59:00) then it creates a new row in auxiliary table, which I then update with stored procedure. Now I was thinking if it is possible to move the logic from application to database (using stored procedure). The programming logic should go as follow:

 1. Trigger is executed when a new row is inserted into the master table. [This is already implemented]
 2. If a date from new row is a new day/month/year, then create a new row in auxiliary table. **[This is what I don't know how to implement in stored procedure logic]**
 3. Update row in auxiliary table.[This is already implemented]

Currently I compare dates in Java application with the help of Joda library which is really easy. But I don't have a clue how could I write this kind of logic in MySql Stored procedure, if is it even possible?