Jump to content

selecting data from mysql for past 12 hours worth of records


rwilmot1

Recommended Posts

Hi Guys,

 

This is my first post so pleas be gentle  :P

 

I have only been coding PHP for the past month or so and have created a log diary. I have set up the fields and calendar entries as well as other bits and bobs. What I want to do now is call data from the mysql database but for records that were created in the past 12 hours, then another report for the past 24 hours, then 36 etc.

 

I do have a timestamp entry in the mysql table.

 

I hope that makes sense???! :confused:

 

If it doesn't then I will try and provide more detailed info along with some code

well one simple way could be such as:

 

SELECT * FROM `log` WHERE `time` > UNIX_TIMESTAMP() - 3600 * 12

 

SELECT * FROM `log` WHERE `time` > UNIX_TIMESTAMP() - 3600 * 24

 

SELECT * FROM `log` WHERE `time` > UNIX_TIMESTAMP() - 3600 * 36

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.