Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Query For Records Older Than A Date?


I need to write a query for a table that has records that are up to 5 years old. I need the query to return records that are older than 6 months only.

There is a date field in the table. Using date_sub and interval I know how to get records between today's date and an interval, but not records older than that interval.

select * from tables where date_checked BETWEEN DATE_SUB(CURRENT_DATE(),INTERVAL n DAY) AND CURRENT_DATE();




View Complete Forum Thread with Replies

Related Forum Messages:
Delete Records Older Than 14 Days
Does anybody know how to make a script that automatically removes mySQL records older than 14 days?

View Replies !
Select Query To Get Only Todays Date Records
I want to use the following query to show only users who registered today with todays date.format(m/d/y)field name is: a.date_registration

select a.id, a.fname, a.sname, a.status, a.login, a.login_count, b.lang_1 as gender, a.email from pro_user a left join pro_reference_lang_spr b on b.table_key=཈' and b.id_reference=a.gender where a.date_registration = (Todays Date m/d/y) order by a.login limit 0, 10 0, 10

View Replies !
How Could I Print Random Date On Set Of Records
How can i get random date on each record which i show from a table. To explain in detail: I'll show 20 records from a table, the first 7 records shld have todays date and the next 4 records yesterdays date and 8 records day after yesterday and so on until the end of record set.

View Replies !
Get Records Betwen Two Date Columns.
Maybe is silly but I know I can find a solution here.  I have this table

id     |     datein         | dateout
1      |   2007-05-11    | 2007-10-11
2      |   2007-06-11    | 2007-10-11

What I'm trying to do is get all the records between date I passed via form.

I tried "Select * from dates WHERE datein >= '$datein' AND dateout <= '$dateout'";
I stored dates as DATE on the DB. I tried to use BETWEEN, but I don't know if I can use on two different columns.

View Replies !
Query Not Reflecting Records
I have a form that submits about 30 fields or so to a mysql dbase. i have verified the functionality of entering data and storing Code:

View Replies !
Sql Query For Find All Records Have Same Id
Lets suppose I have a table like this one

idid_1id_2 date_time
110110002006-07-04 11:25:43
21021001 2006-07-04 11:26:43
310110052006-07-04 11:27:43
410310002006-07-04 11:25:43

I want to find all records have same id_1, but different id_2 and have difference in time less than 5 minutes. In this case this is record 1 and record 3. How can I do this ?

View Replies !
Database Records Query
Can anyone help me with the following mySQL code. Probably a simply solution but i cant find the answer anywhere. I have a table called news full of articles each one has an associated news_id. What i need to do is query the database and pull out the last article. Then i want to pull out the second to last article and finally the third to last article.

View Replies !
Count How Many Records Have Been Found In The Query?
I just wanna know how to do a function to count how many records have been found in the query?

View Replies !
Very Slow MySQL SELECT Query After 11 Records
I have a very weird problem

I moved my database to new IIS 6.0 + PHP 4.3 + MySQL 4.0 setup. I tried to check with myphpadmin if everything works fine, but I couldn't browse my table (125 records). I used SELECT option and found out that SELECT query up to 11 records is ok, but after that, even if I choose to limit query to 12 records, it just hangs.
I tried selecting from the beginning of the table and from the middle - same thing, but when I run query localy on mysql console, everything works fine

View Replies !
Query Returns All Records In Php5 (but Not Php4)
I am moving all my PHP sites form a server running PHP 4 to a new server running PHP 5 Having trouble with a URL passed variable or the query syntax.
URL calls a PHP page and passes a variable: Code:

View Replies !
Sql Query For Count Records Of Current Week
I have a registration form that saves the registration date on a datetime column. I would like make a query to know how many records are in the table that where for the current week.

For example, I'm on week 25 and I want to know how many records I have for this week without the need of specifying the from and to dates. Is there a way to do this?

View Replies !
Create A Sql Query That Will Select Records By Selecting A Month
I am trying to create a sql query that will select records by selecting a month. So for example I have to create a query rhat will select all entries between 1st jun and 1st july (1117609200 and 1120201200) which should not be that hard. Is there a function that will generate what the timestamps should be automatically instead of me having to calculate them manually.

View Replies !
Query Problem: Counting Records From Another Table Without Using A Subquery
I'm working on a rather complex SQL query, which retrieves a list of clients that match certain criteria. One of the criteria I need to test is the number of business days that have elapsed since the client's enrollment.

To facilitate this, I've created and populated a table called business_days - containing one record for every business day (non-weekends and non-holidays) for the next ten years. Using this, I can just count the number of business_days between two dates, like this: Code:

View Replies !
View The Query Results One Record At A Time And Cycle (step) Through The Records
I need to know how to use PHP to step (one by one) through the records of MySQL database query result. I am able to connect to the DB and perform a query. I am able to print the results of the query for the ENTIRE query result.

What I need now is to be able to view the query results one record at a time and cycle (step) through the records by using a control (button or link) on the page itself. (The first record of the query result displayed on page entry, a "next" link/button to see the next row of information).

View Replies !
Older PHP Manuals?
I'm trying to use the DOM XML functions, but because they're in development and my hosting provider only has 4.0.4 installed, I don't have the proper documentation. Does anyone know where I can locate an older version of the php manual?

View Replies !
Clearing Up Older Files
Wonder if you bunch can help me (again!)... i'm looking for a way to read the filenames and dates in a directory, and delete everything which is more than 24 hours old.

It's gonna be part of a garbage cleaning routine for old temporary downloaded files.

View Replies !
Php Compatable With Older Browsers
are all the functions of php compatable with older browsers? if not what functions don't work?

View Replies !
Show Older Entries
I have a MySql table with the field "sentdate". How could I set up a query that selects only entries that have a sentdate that is for example 30 days old?

View Replies !
How Do I Get First Timestamp Older Than 24hours?
I would like to query results of post timestamps (say 10 results sorted in DESC order) and have it read the timestamp of the most recent... Then go through the remaining 9 results and return the next timestamp that is at least 24 hours (or 86,400 seconds) old or older...

Is an if/elseif/else the only way to do it or is there something more elegant/efficient?

Also, is there a way to stop it if there aren't 10 results available?

View Replies !
Download PDF In IE6 Older Versions
I have a script to download text and pdf documents from a site but am encountering problems in older versions of IE. I have adapted the script that we have in house to the following. If anyone can spot out any flaws or offer critique please comment. The main problem the client has is that a white screen appears when the button is clicked.

<input type="button" value="Download" onclick="window.location='/about_us/jobs/?action=downloadFile&amp;documentID={$key}'" />
private function downloadFile()
{
$documentID = intval(stripslashes(strip_tags($_GET['documentID'])));
if ($this->db->fetch_result($this->db->query("SELECT COUNT(*) FROM job_documents WHERE documentID = $documentID"))!=1) {
header('Location: /about_us/jobs/');
exit;
}
$jobID = $this->db->fetch_result($this->db->query("SELECT jobID FROM job_documents WHERE documentID = $documentID"));
$this->forceDownload($documentID,$jobID);
...

View Replies !
Delete Files From A Dir Older Than A Week
The below should delete files from a dir older than a week. I set the $dtime to 0 to test the script but it deletes nothing. What is wrong? Code:

View Replies !
Delete Entries 1 Week Old Or Older.
I have a query that's supposed to remove bulletin entries that are a week old and over, but its not working, and the "date" column is filled with "time();"

<?php mysql_query("DELETE FROM `bulletins` WHERE `date` > (time() + (3600*24*7))");?>

View Replies !
Delete Record If Older Than 5 Minutes?
Can someone help me in writing a query command, to delete a record, if the last_update field on a record is older than 5 minutes?

My table has a last_update field, which holds a value as this for example: 2007-04-08 01:33:12

I need a query that when I access a php file, if a record is older than 5 minutes, it will delete it.

View Replies !
Deleting Older Entries.. (mysql)
I've a comment form.. I've allowed only 10 comments to be viewd, so when I submit new comments, I want to know how to delete older ID comments except the latest 10 comments. Means if there are 13 comments.. 13...3 shd be there and very 1st and 2nd(older) comments must be deleted.

View Replies !
Detect MSIE Older Than Using Less Than Operator?
Here is my attempt at detecting an MSIE browser (in this instance, older then 5.5). The first part works fine but I'm still in the wrong valley as far as the browser's version number goes. Code:

View Replies !
Further Date Query....
I have my compiled date function working, thanks to a devshed user , It enters the start date. which can be set manually by the administrator as they may not want to start their contract for three weeks after subscribing etc. This works fine. The end date should be set by the contract length that is chosen in create user. Month / Quarter / Annual and a few others....can I make

$end_date = ($compiled_start_date, +365); and if so, would it enter it into the db as the same format that start date goes in which is 2003-MM-DD?

Also - does anyone have any suggestions for automaticall setting my start date form fields to today's date? I have three fields, days, months, year (year is non-changeable so is not a problem).

View Replies !
Query After Date
how can i make it so when i query my database for my current events it only shows the ones after today. So like if today where to pass and i had and event on 9-06-07 it wouldn't show up? Here is what i have for the pull

$events_query="SELECT * FROM ".$glob['dbprefix']."StreamRush_events WHERE customer_id=".$ccUserData[0]['customer_id'];
$events_table = $db->select($events_query);

i have no clue what the synax is for that..

View Replies !
SQL Query For Date
I have a SQL table with a list of dates

1/ 2006-15-04
2/ 2006-09-05
3/ 2006-15-05
4/ 2006-24-05

I have a code to see that the date today is 2006-07-05 how i write a code to select the closest date to today... ie: row 2 .

View Replies !
Date Query
I am trying to extract some information from a mysql database. Basicaly i am trying to count how many items where submited on a monday tuesday etc I have looked around but have been unable to find a script or snippet that would help me achieve this. i am running PHP Version 4.3.11 and Mysql Version 3.23.49.

my dates are stored using the datetime format 2006/20/12 00:00:00 and am wondering how i can count these based on the day it was entered. Likewise I would like to show perhaps the most popular time filed for example 00:00:00 - 02:00:00 and so on in like 2 hour chuncks if this makes sence.

View Replies !
SQL Query By Date
I have a $date variable in the mm-dd-yy format which is picked from the server's date and related to the record insertion date. I need to select the 10 LATEST ADDITIONS to that table. how can i write this SQL query?

View Replies !
How To Query According To The Date..
Id like to have a query depending on what is the date today. Its like a sort of reminder.

example. I have insert an action "Call Mr. Smith" and the date assigned is 2007-08-29 so by tommorow when i open my list of actions it will appear the the said "Call Mr. Smith" .

my query is

Select * from schedule where enddate<=NOW()

but this query will display all the enddate that less than 2007..

View Replies !
Deleteing MySQL Rows Older Than 1 Hour
Hi, as the title says, I have a mysql table which logs data, I have a timestamp field which collects what time the record was added, I really need to know howto setup a WHERE clause which will tell mysql to delete rows that are older than one hour, can anyone help?

View Replies !
How To Delete All Database Entires Older Than 30 Days?
One of the fields in my database is called ad_date which is of date type and stored dates int he format YYYY-MM-DD. I would like to perform a DELETE SQL statement in my PHP script which deletes all records with an ad_date value older than 30 days.

I knoy this is also an SQL question, but it is the 'older than 30 days' part which I'm stuck with and so figured it would be better in the PHP forum as I think I need to use PHP to calculate todays date - 30 days.

View Replies !
Older GD Lib And Jpeg Photo Thumbnail Generation
I'm using a server which only has GD version 1.6.2, with jpeg support
enabled. I'm trying to use it to make thumbnails of jpeg photos as they are
uploaded from a webform, but moving from my development server (which has GD
2.x) to the real server I noticed the lower GD lib version, and that it
doesn't support imagecreatetruecolor. Without this, using imagecreate, the
converted image always come out almost always a single colour, or with very
little variation in the colour. Using some images I found in XP as a test,
one has green plants with a few bright red flowers - if i just use
imagecreate, the bright red flowers are green too. I'm using
imagecopyresampled to do the copy. Is there another way to do this without
getting newer libraries installed on the server?

View Replies !
Dates - Mysql Database Older Than 7 Days
I would like to delete all the records in mysql database that is older than 7 days.
How do i go about selecting it in the database ( currentdate - 7).

View Replies !
MYSQL PHP Code Works With Older Version.
I am having issue with they way that my PHP MYSQL code works with the MYSQL version 5.0.45 Here is the Code that inserts the data into the database. The thing is the tables that have a int in MYSQl error when there is no value present. Code:

View Replies !
MySQL Dont Show Older Than Today
I'm making a database for upcoming shows. so, what I wonder now, is there a way to show only upcoming shows, and just exclude the shows older than todays date? what I've got atm is: Code:

View Replies !
Update Query - Way To Update All Records That Meet Only A Part Of Field
I know that if you use the following code..

UPDATE
table
SET
field = ""
WHERE
field1 = ""

than it will change `field` in all records that meet the criteria of field1. What I need to know is there a way to update all records that meet only a part of field1

ie...

UPDATE
table
SET
field = "yummy"
WHERE
field1 = "apples|oranges"

if field one contains apples|oranges|grapes

it would still pick up that record.

View Replies !
Mysql Date Query
I need to check if one script was run later than one hour ago - I had a problem with cron and want to put in a safety code.

On successful running of the script I remember the date in db
CREATE TABLE log(id INT NOT NULL auto_increment, ttime DATETIME, other_info TEXT, PRIMARY KEY(id));

The sql query that I use now is:
SELECT HOUR(CURDATE() - ttime) as h FROM log ORDER BY h LIMIT 1;

However I have a problem - it returns sometimes value NULL (which is always first).

If I use the following syntax:
SELECT HOUR(CURDATE() - ttime) as h FROM log WHERE h IS NOT NULL ORDER BY h LIMIT 1;

I get the error: Unknown column `h` in `where clause`. What can I do?

View Replies !
Date/MySQL Query
I am making an event calendar that allows users to add events. An event can possibly span multiple days so I made two fields for start date and end date. This all works fine.

I want to be able to grab the data out of the database through a query and display it on the webpage in order of date. So I'm ordering by the start date. However if the event is 3 days long I want to show the event on the page 3 times, with all other events in between also show. I have not been able to figure out the logic on how to get the event to show up 3 times with other events in between them?

Sample Data:
Event 1 Dec 31 2002
Event 2 Dec 31 2002
Event 1 Jan 01 2002

View Replies !
Sort By Date Query
I have a gallery website that has a search facility and im trying to work out how to amend the php so the results are shown by newest photo first.This is the code.  I dont even know where to start looking. I looked at the usort section but I didnt see anything that made sense to me to amend. Code:

View Replies !
Query Date Range
I have a table which holds a bunch of dates

id   datefrom       dateto
1    2007-02-22   2007-03-05
2    2007-05-13   2007-06-23
3    2007-05-25   2007-07-23

the `datefrom` and `dateto` are dates in the format YYYY-MM-DD, the `datefrom` means the date the event starts and the `dateto` means the date the event ends.

What I want to run a query on this table and return any rows which have todays date between the 'datefrom' and the 'dateto'.

Does that make much sense?

View Replies !
Php Query To Select Min Date
im trying to get a minimum date from my database, the current way im doing it is:

SELECT * FROM events where Date > NOW() OR Date = '9999-12-12' ORDER BY Date ASC LIMIT 1

this works in terms of code, but it doesnt do what I want it to do. Its the ORDER BY Date, that is the problem: What I want to select is

The next date OR a date = 9999-12-12

I tried searching for a query like "select MIN date" but couldnt find anything on it, plus the date has to be in the future, hence the need for DATE > NOW()

quite confusing I know!! but any advice?

View Replies !
Query For Last Record Before Certain Date?
I have a table with three columns as so: username (varchar32), punch_type (enum), and punch_date_time (timestamp). Given a date, how can I extract the last punch before a given timestamp for each user? More specifically, I'm building a new timeclock system for my employer. Given a date, I need to know the last action on the timeclock for each user that occurred before the start of the new pay period.

I have something functional but it requires logic in the script and multiple queries to make it happen. Since all of the requisite information is in the database, I don't see why I shouldn't be able to extract thei nformation I'm looking for in one query. If it helps, I have another table of employee usernames that I might be able to use in a join of some sort to isolate these timeclock records.

View Replies !
Date Query 6 Months
May I ask for help with a query. I need to send a scheduled email out to registered users, 6 months after their registration date. Therefore I need to create a file that I can cron. I'm thinking "now" equals registered date plus 6 month.

View Replies !
Date And Mysql Query
i search to do a query between two age between 18 (search_age_from) & 30(search_age_to) year for exemple. My query is going to ask on a db where there is no age field, but a birthday field ( build with the time past since 1970).
In my db so birthday in like this : 1130832000. actually i do the following query :

$query = mysql_query("SELECT * FROM * WHERE birthday BETWEEN('$search_age_from','$search_age_to') ....

and of course it's not running. Some body can help me to do the good query? i'am newb and have so prob to convert age in good format before doing query.

View Replies !
Calculating Date Query
I've been asked to develop a script where it displays todays news according to today's date, and then to display news items 5 days prior to todays date. Interesting problem, I think. Basically all the news items are stored in a database

itemid int(11)
heading varchar(255)
prop_date varchar(255)
content text

So I need to select heading according to todays date, then another select heading 5 days prior to todays date.

View Replies !
Format Date Query
How do I convert the below into this format: 09/01/2006 Want to remove the time also. Jan 9 1900 5:20PM

View Replies !
Query Based On Date
i was wondering if this was possible as I cant quite think how (maybe too early in the morning) I need to run a query based on the last 6 months of entries.

In my table i have the usual headers e.g. name and body of text etc, but also a date_created column with stuff like 2005-12-20 15:44:37 in it.

View Replies !
Date Range Query
how to make a php mysql query that would return only data inserted in the last 24 hours? I have a dateSubmitted datetime field in the database already.

View Replies !
Migrating Existing Site From Older Version Of PHP & MySQL
There's an existing website (on a single box running Linux, Apache, PHP 4.1.2, MySQL 3.23.58) that I need to migrate over to another setup (2 boxes, the web/app server running MS 2003 Server, IIS6, PHP 5.2.4 and a DB box running on SuSE, MySQL 5.0.26). I've gotten the connection between the two new boxes to work, but a lot of the code from the original website doesn't seem to work.

Is there anything obvious I should know about migrating code from the older setup to the newer one, which is running different versions of PHP and MySQL. I've attached 2 php files (both renamed to txt). When I bring up the dir_master.php file, the only thing that comes up is the Name, Affiliation, and Department headers from the contents.php file.... nothing gets displayed from the MySQL database. Like I said, I have been able to pull stuff out of the DB using code I wrote myself to test it, so I'm sure the PHP to MySQL connection is working.

I think the issue might be with the PHP code and how the HTML is embedded in it, but like I said, this isn't my field of expertise. I'm hoping there's a quick syntax fix that I can use without having to completly rewrite everything.... especially since there's a number of PHP files that will need to get changed.

View Replies !
Working With Dates - Entries Older Than 2 Weeks To Be Deleted From The Db
I'm having the a date stored in my db in yyyy/dd/mm format. I want all the entries older than 2 weeks to be deleted from the db. How can i do the calculations to find if the entry was added more than 2 weeks ago?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved