shane85 Posted April 5, 2010 Share Posted April 5, 2010 sorry for all the posts on this today...I cant think straight for some reason when my form submits, it gives a timestamp of when it was submitted theres also a drop down which is where "contact_next" is chosen from...im using strtotime +1day 2day 3day etc. to enter in the information into my db. now if I want to display my querys by contact_next, how would I do the subtraction to show, for example timestamp: 2010-04-05 contact_next: 2010-04-08 obviously the difference there is 3 days....if thers entries for 1 day, 2 days, 3 days etc. I want it so that when viewing by "contact next" the 1 day will show first...then 2, etc etc etc. Also once the "contact_next" expires, ie. todays timestamp would be ahead of that field, to not show those expired results. Link to comment https://forums.phpfreaks.com/topic/197683-subtracting-1-date-field-from-another-in-mysql/ Share on other sites More sharing options...
ignace Posted April 6, 2010 Share Posted April 6, 2010 SELECT * FROM table WHERE contact_next > now() ORDER BY contact_next Add a LIMIT if you want to limit the number of rows returned Link to comment https://forums.phpfreaks.com/topic/197683-subtracting-1-date-field-from-another-in-mysql/#findComment-1037623 Share on other sites More sharing options...
shane85 Posted April 6, 2010 Author Share Posted April 6, 2010 ignace: works perfectly! now my next question is if todays timestamp would be 2010-04-05 and I have a record that would be 2010-04-04 would it show that record as the first one? (this is in ASC order) or would it display last since the time isnt next, its already expired??? Link to comment https://forums.phpfreaks.com/topic/197683-subtracting-1-date-field-from-another-in-mysql/#findComment-1037627 Share on other sites More sharing options...
shane85 Posted April 6, 2010 Author Share Posted April 6, 2010 just tried changing it in my db to a day from yest and i doesnt display...perfect. Link to comment https://forums.phpfreaks.com/topic/197683-subtracting-1-date-field-from-another-in-mysql/#findComment-1037628 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.