Jump to content

Brain Freeze


Anidazen

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.