![]() We will create one PHP page with this query for easy understanding of the application. SELECT To_days( dt2 ) - TO_DAYS( dt ) FROM `dt_tb` PHP COde with Query You can get the sql dump of the table at the end of this tutorial. Here is the sql query applied to a mysql table and the result is shown. You can get many such applications where difference in days are required. SELECT '' as Checkin, '' as Checkout, (TO_DAYS( '')-TO_DAYS( '') )as No_of_DaysĪnother example is in library if we are finding out the difference in days between date of issue and date of return. Both the fields are date and time fields. 4.) I selected the field through the same jdbc connection I used for step one and two and got the stale value. 3.) I selected the field through the mysql console and retrieved the correct up to date value. 2.) I updated su on this new row to 1 and committed the change. After converting that can be simply subtracted to get the difference.Įxample of such a application is to find out the days a guest has stayed in a hotel, we have to take the difference of arrival date and departure date. 1.) I inserted a new row, setting su to 0. Returns difference in days between 0 date and the date given.ĭifference in date between two date columns in a table can be found out by converting the columns by using to_days function. ![]() TO_DAYS(): Difference in days between two date fields of a record
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |