gabs Posted July 11, 2006 Share Posted July 11, 2006 Hi, I would be grateful if somone can point me in the right direction here...I am querying a data base and want to get dates between a start date ($sdate) and end date ($edate).. then if there is more than 60 entries..i want to use every 30th entry ( so that I effectively use months) if it there is more than 730 entries (2 years) I want to use every 365th entry ( so that I use years effectively) i can't get the code to use and are not even sure how it is suppose to look like, I would be grateful if someone can help me here...[code]$query = "SELECT date, CONVERT(varchar(12), date, 111) AS 'converted' FROM Enquiries WHERE date BETWEEN '".$sdate."' AND '".$edate."'"; $result = odbc_exec($conn, $query) or die (odbc_error()); while ($row = odbc_fetch_object($result)){ array_push($day, $row->converted); $dates = array_unique($day); $amountdays = count($dates); if ($amountdays >= 730) { for( $i = 0 ; $i < $amountdays ; $i += 365 ){ array_push($array_y, $dates[$i]); } } else if (($amountdays < 730) && ($amountdays > 60)) { for( $i = 0 ; $i < $amountdays ; $i+= 30 array_push($array_y, $dates[$i]); } } else { $array_y = $dates; } }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14277-using-dates-in-days-months-years/ Share on other sites More sharing options...
hvle Posted July 11, 2006 Share Posted July 11, 2006 is this mysql? Quote Link to comment https://forums.phpfreaks.com/topic/14277-using-dates-in-days-months-years/#findComment-56128 Share on other sites More sharing options...
gabs Posted July 11, 2006 Author Share Posted July 11, 2006 It is a SQL server using an ODBC driver...but don't let that put you off it works exactly the same.. Quote Link to comment https://forums.phpfreaks.com/topic/14277-using-dates-in-days-months-years/#findComment-56201 Share on other sites More sharing options...
hvle Posted July 11, 2006 Share Posted July 11, 2006 gabs, good to know that.well, i don't understand EXACTLY what you wanted to do, but I think you will need these:to find out how many entries:select count(*) from table where ....to select entry 30th:select * from table where .... limit (29,1)above statement skip first 29 entry and return only entry 30th.same goes with 365th entry.using between is correct.So, yeah, try to put them together and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/14277-using-dates-in-days-months-years/#findComment-56207 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.