![]() |
SQL Query based on last 48 hours?
I have a PHP file that I run as a cron task every 24 hours. Can some one help with a tweak to the query to only select matches that have occurred between the time the query is executed and through 48 hours before?
PHP Code:
Code:
$urls = mysql_query("SELECT linkid,linkurl FROM adv_links ORDER by linkid ASC"); Any help would be appreciated! Thanks, |
Is there a time column in your table?
|
Yes there is - its "dateline" and as an example under PHPMyAdmin the field looks like "1207498258" for a particular entry. I am unsure how to read that with the SQL query and translate that to what I need.
Thanks for the reply, |
PHP Code:
|
Thank you very much for the help. I'll give it a try.
|
More easily done within mysql
...where unix_timestamp() - timecolumn <= 3600*48 |
After many frustrating hours I'm still having a problem. I have tried multiple ways of writing the SQL query line but it still is not correct. I am using this code
PHP Code:
Thanks, |
Try:
PHP Code:
|
Quote:
Quote:
Other thoughts? --------------- Added [DATE]1210086427[/DATE] at [TIME]1210086427[/TIME] --------------- Quote:
Thanks, --------------- Added [DATE]1210108992[/DATE] at [TIME]1210108992[/TIME] --------------- PHP Code:
Quote:
|
"timecolumn" is whatever field in your database contains the dateline data
its kicking an error because you dont actually have a field called "timecolumn" It looks like your field is called dateline, so the sql is [sql] SELECT linkid,linkurl FROM adv_links ORDER by linkid ASC WHERE unix_timestamp() - dateline <= 3600*48 [/sql] |
Quote:
|
Quote:
PHP Code:
Quote:
Quote:
Thanks, |
PHP Code:
|
Thanks again but I still get the same error. I'm sure the DB connection is good as I can use the original query with no problems. I'm going to post the entire code also. Sorry to be of so much trouble.
Quote:
PHP Code:
|
Lol, mistake (in all these examples!!) you get by editing code and not read good what the result is.
The following is valid: PHP Code:
- TIMENOW is only defined within a vBulletin environment, so replace by time() |
Sucess! I was not aware that ORDER must always follow WHERE. I thank you ALL very much!
Regards, |
All times are GMT. The time now is 05:26 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|