Day of the month can be collected from the date and time field by using the function day(). This will return day in number format and we can apply calculation to this. Note that this will not take care of month and year, for example the difference in days between 12th July 04 and 14th July 05 is two days only.
The basic query is here
SELECT day(dt2) FROM `dt_tb`
This will collect the day part from the field
For easy understanding we will create one PHP page with this query with all other fields.
Difference in Day
The sql query is modified to display all the columns with the days and their difference for easy comparison. Here is the query used.
$query="SELECT dt,dt2,day(dt) as day1,day(dt2)as day2,(day( dt2 ) - day( dt )) as difference FROM `dt_tb`";