Anidazen Posted April 19, 2007 Share Posted April 19, 2007 Hey guys. My mind's just gone completely blank today and I just can't for the life of me work out how to return records from an SQL table from the past 24 hours / the past week / the past month. Can't find the info I need either and I KNOW it's in like a thousand places... Couldn't find anything that tells you what to set the MYSQL variable type to when you create the table and how to structure the queries. Could somebody just show me a quick demo of how to do this? Thanks a lot. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted April 19, 2007 Share Posted April 19, 2007 Ok, there is no straight forward way to do this using just sql/php. You have to put some manual work into it. You need a field int he database for the date, or time or some other kind of identifier of exactly "when" the records where entered. Then with that it will be simple just running a query and check for a range of date's, or dates in general. However you want to (no matter how you are setting up the dates) you wnat to save them as unix timestamps, then you can do any types of search with them a lot easier, and a lot more affectively. Quote Link to comment Share on other sites More sharing options...
Anidazen Posted April 19, 2007 Author Share Posted April 19, 2007 Business - thanks for your reply. I am still confused though, and Googling for tutorials is being surprisingly unproductive on what I would assume is such a basic thing. Could someone show me some samples of working with time? I need to know: 1) What to set the field type to in MySql Admin. 2) What a query should look like for SELECT * from X where X < a week ago. 3) What variable I need to pass for this in the INSERT query too -- or just leave it blank? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.