t_machine Posted January 23, 2007 Share Posted January 23, 2007 hi, I am wondering if anyone could help with this problem I have.I have a large list of records, each with the date they were stored in the database. How can I display only the records entered within a certain data period.Example$sql = "SELECT * FROM _table where date_added is between 07,Dec,2006 and 23,Jan,2007I stored the date as time stamped time()..I think I would have to format the date_added column like this -> DATE_FORMAT(FROM_UNIXTIME(date_added), '%d,%m,%Y') but how do I check if it's between the above time period.Thanks :) Link to comment https://forums.phpfreaks.com/topic/35393-how-to-find-records-between-two-dates-in-mysql/ Share on other sites More sharing options...
paul2463 Posted January 23, 2007 Share Posted January 23, 2007 if the dates in the database are timestamps then just change the dates you are searching between into timestamps too and then use the variable sin your query[code]<?php$start = strtotime("07 December 2006");$end = strtotime("23 January 2007");$sql = "SELECT * FROM _table WHERE date_added BETWEEN '$start' AND '$end'";?>[/code] Link to comment https://forums.phpfreaks.com/topic/35393-how-to-find-records-between-two-dates-in-mysql/#findComment-167375 Share on other sites More sharing options...
t_machine Posted January 23, 2007 Author Share Posted January 23, 2007 Thank you very much :) Works perfectly. Link to comment https://forums.phpfreaks.com/topic/35393-how-to-find-records-between-two-dates-in-mysql/#findComment-167409 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.