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.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.