Jump to content

subtracting 1 date field from another in mysql


shane85

Recommended Posts

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.

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???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.