Jump to content

Select previous day timestamp


jtelo

Recommended Posts

I have a table with the columns code, user and date (in the timestamp format. Example: 2010-07-09 11:23:42).

 

I'm trying to make a query with PHP and mySQL to return the rows with the timestamp of the previous day, but can't make it work.

 

Can someone please help me?

Link to comment
Share on other sites

I am no expert but as the time stamp in a number of units sine inception I would have thought using now() and minus the figure for 24 hours would do the job ??

 

Just a thought

Topshed

 

With this i get all the rows of the previous days, but can't make it return only one day:

SELECT * FROM table WHERE date<NOW()

Link to comment
Share on other sites

SELECT * FROM table WHERE DATE(date) = CURDATE() - INTERVAL 1 day

 

Thank you all for the help. I got what i wanted with this:

select * from table where `date` BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND CURDATE()

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.