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


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





Timestamp :: Select Rows Inserted In 2 Weeks Time


I've got a TIMESTAMP(12) field in a table and I need to select all the rows that have been inserted or updated since 2 weeks (14 days) ago from the actual date each time the query is executed. How the heck can I do it?




View Complete Forum Thread with Replies

Related Forum Messages:
Timestamp :: Automatic Delete After 2 Weeks
I'm making a classifieds website in PHP/MySQL and I have everything working, except my client wants each ad to automatically be deleted after running for 2 weeks. I have a timestamp value for the add storing when it was added, but I have no idea what kind of value to set for delete day/time and how to get it to check if it is past that time and delete it.

View Replies !
Select Rows From Date Not Time In Where Clause
I am trying to select all the rows that where entered today and I have a datetime type column to store the date data in. How can I specify in my where clause to select where datecol=today and not have to specify the time? If I do where datecol=<?php date('Y-m-d'); ?> its not working

View Replies !
Dumping Specific Inserted Rows
I need to do a mysqldump of specific inserts, updates & deletes. I read in the docs that I can use -w or --where. Can I do a join?

View Replies !
Select Last Inserted Data
I've two columns: the first with the value and the second with the time.

value time
0 06:50
2 06:55
10 07:00
5 07:55

i've to select the value with the max time. I thought to use:

select value from table where time like max(time);

but it doesn't work :-( (error message: Invalid use of group function)

how can i solve the problem??

View Replies !
SELECT Last Inserted Autoincrement Value
most efficient way to retrieve the auto-incremented field value of the recent inserted record.
Is there any better way rather than running SELECT after INSERTing the record ?

View Replies !
Timestamp :: Add 7 Days Time
How do i display a date as a new column 7 days after the initial timestamp eg.
current timestamp = 20050310000000

if i add 7 days to this won't it result in 20050317000000
eg SELECT *, DATE_FORMAT('%d/%m/%Y' , (dateAuthorised+7)) as expiryDate

I know this is the wrong approach as the timestamp 20050330000000 would cause an error

View Replies !
Add Time In Minutues To A Timestamp
How do you add / subtract time in minutes to a timestamp?

SELECT * FROM users WHERE chatOnline BETWEEN '2008-12-27 12:35:16' AND '2008-12-27 12:35+40:16'

View Replies !
Dates In The Past 3 Weeks (was "SELECT Query Help")
I'm trying to select data from a table that has been submitted in the past 3 weeks. I am not having any success.

View Replies !
Timestamp - Making It Stamp The Time
This is wrong:
ALTER TABLE members CHANGE COLUMN startday DEFAULT NOW();
But it may convey what I want.
I created a table with a column called startday which I made a data type of timestamp which I had hoped would fill the field when a record is added. But no.

How do I alter the table column so that it will fill wiit the trimestamp of when the record is added?

View Replies !
TIMESTAMP :: Query By Time And Date
I have a field in my table that holds a timestamp. Below is a pseudo-query to describe what I would like to do.

SELECT * FROM `mytable` WHERE `saved_date` <= `6/24/05 10:22:34 AM`

`saved_date` is the field holding a TIMESTAMP. If anyone could give me the query that would actually do what I am trying to do above,

View Replies !
Time Difference Between TIMESTAMP Fields
Anyone know how to return the difference in time (in seconds) between two TIMESTAMP fields?

I am using MySQL ver 4.0.12 thus TIMEDIFF and all those other fancy functions dont work!

View Replies !
Changing The Default Time Zone Of A Current Timestamp In MySQL
I have a shared host which uses the time zone MST (GMT-7), and I cannot seem to change the time zone for my own database.

What is the best way to create a timestamp field in a table that has the default value be the current time in GMT-0?

Is setting the default value of the timestamp field to "DATE_SUB(NOW(), INTERVAL -7 HOUR)"

View Replies !
Table Rows Inserted By Embeddded MySQL Cannot Be Retrieved By MySQL Tcp Client
I have encountered a weird behavoir of embedded MySQL. Through a
simple program I made (in Delphi 6), I can insert rows to a table
through embedded MySQL and I can retrieve the rows from my program.

But using mysql.exe which points to the same table (through 127.0.0.1,
with the same basedir and datadir), I cannot see the rows I inserted
using my embedded program. Another way around, the rows inserted by
mysql.exe can be seen in my embedded program. But after a row is
inserted by mysql.exe, the rows inserted by the embedde program are
deleted (or cannot be queried).

Can anybody explain why is this? Is there a way to fix it?

View Replies !
Selecting Timestamp Rows
What is the best way to select date ranges with a time stamp?
This is the query I'm using:

"SELECT keywords, DATE_FORMAT(time_stamp,'%m %d, %y') as 'date' from keywords WHERE time_stamp >= '".$start_date."' and time_stamp <= '".$end_date."'";

Its returning dates a little bit outside of the range. Its off by a month a so.

View Replies !
Selecting Rows From Timestamp Field
I've got a database with al lot of rows. Each row has a timestamp field, wich indicated the time that that the row was added. The timestamp field is generated by time().

Now, my question, how can I get all the rows, for specific day? So I would like all the rows from yesterday, or 12 days back, or 3534 days back.

View Replies !
Filtering The Rows Based On Its Timestamp
I'm trying to write a backup script that takes the last modified rows of a table in x days. I can do it if I have a timestamp column for every table in the database, but my aim is to write a script for general use as anyone can use it with his/her database without the need to add that column.

This will be possible if there a property gives the last modified timestamp of a row.

does anybody has any way to reach that target?

View Replies !
SELECT MAX :: Timestamp Values
I have such a table

id
value
timestamp

I would like to select the newest three timestamp values for each id, can I do that with an SQL query?

I can easily get the MAX timestamp values for each id, which gives the latest, but coudl I select somehow the latest three for each, sg like MAX 3? :)

I can also select the latest three timestamp values for an id via select limit 0,2 but then I would have to do a php foreach.

View Replies !
Unix Timestamp Select Query
I am having trouble with the following sql query.I am trying to select all records in the future where the date is greater than today but to include today, the date field in the db is an unix timestamp.


Code:

"SELECT * FROM mysqltable WHERE mysqldatefield > now()-1 ORDER BY mysqldatefield DESC"

View Replies !
Select Where Date = Today Timestamp Field
I have data stored in mysql table with a field (date), the data stored inside the field (date) is timestamp, how can i select data from this table where date = today (Current Day) ?

View Replies !
Sum Of Time In Multiple Rows
I have a table

Code:
TASKS{
started => time column,
ended => time column
}
Now, for every task I do I make a new record (e.g.) saying I started at 11:00 and ended in 11:15

Now, I can find how long I worked PER row (e.g. in past example the following would return 15 min)

Code:
select subtime(ended, started) as time from tasks

How do I sum all the rows, not just one?

View Replies !
Insert 4096 Rows At A Time
I need to increase a fair amount of rows to a mysql table (3.5 million to be exact). I'm doing that with a php script, but for some reason I can only insert a maximum of 4096 rows at a time. Anyone has an idea why?

View Replies !
Inserting Text To All Rows At A Time
I need this very quick, sorry if this is answered already in this forum.

I need to insert some text at the beginning of all rows in a database,

View Replies !
SELECT Rows With Field Different From Previous Rows
I have a table (sens_samples) with mysqlerature sensor samples taken every 5 minutes. Rows are: id (INT), sensor_id (INT), timestamp (DATETIME), mysql(FLOAT) and over_mysql(BOOL).

I want to make a query to get ONLY the rows when over_mysql field changed from "previous" row value. I know that database rows are UNORDERED, but ORDER BY can "place" them in a given order.

My query may be "syntactically" something like: SELECT timestamp, mysql FROM sens_samples WHERE "PREV_ROW".over_mysql <> over_mysql AND sens_id = 1 ORDER BY id;

How can I get it using MySQL?

View Replies !
2 Weeks Past Date
I have a form with a date .i need to display records of the form from the database and display all records of 2 weeks from the present date i.e 14 days record..so how to get the date 14 days back from current date....

View Replies !
SELELCT Dates That Are Greater Than 4 Weeks Old
DELETE tbl_Events
WHERE Event_EndDate < #DateAdd("ww",-4,now())#

The error code I get is this...
Syntax error or access violation: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE Event_EndDate <'2008-07-08 19:02:35''

View Replies !
Selecting Past 12 Weeks Records
Im trying to grab the past 12 weeks records in a table. here is my code:

$query1 = "SELECT * FROM table2 WHERE compdate > DATE_SUB(NOW(), INTERVAL 12 WEEK) ORDER BY compdate";
if($result1 = mysql_query($query1))
{
$amount = 0;
while($row = mysql_fetch_array($result1))
{
$compdate = $row['compdate'];
$compdate = substr($row['compdate'],8,2);
$compdate = ltrim ($compdate, "0");
$days_array[$compdate] = 0;
}
}
else
{
echo mysql_errno().": ".mysql_error()."<br>".$query1;
}

And here is the error:

1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WEEK) ORDER BY compdate' at line 1
SELECT * FROM table2 WHERE compdate > DATE_SUB(NOW(), INTERVAL 12 WEEK) ORDER BY compdate

View Replies !
How To Calculate Weeks Elapsed In MySQL V4.0.25
Can anyone provide an example of the most straight-forward way to determine if a datetime field in a table is from the future, the current week, last week, or the 3 months previous in MySQL v4.0.25? The TIMESTAMPDIFF function looks promising but it's only available in v5.0.

I'd like to pass something to the WHERE clause of the query.

View Replies !
Date Function :: Return Records From 2 Weeks
I have a time stamp field in my orders table and I want to form a select statement where it returns all orders with an order time of two weeks ago from the current time or later so I can keep better track of unpaid orders.

Here are the fields for the orders table
orderID
order_time
order_status
etc...

SELECT orderID FROM orders WHERE ???? AND order_status=2 ORDER BY order_time ASC

Thanks for any help. The date functions are a little confusing to me from the manual.

View Replies !
Can I Tell How Many Times A Column Has Been Updated In The Past 2 Weeks?
I have a table with a column that tracks the number of hits an item receives.

Is it possible to find out how many hits an item has received in the past 2 weeks, without altering the structure of the table?

View Replies !
Don't Select Rows That Match Both Columns But DO Select Rows That Don't Match Both
I suppose it is because it is 2:30 AM but I'm having a bit of trouble figuring out the SQL I need to write. I am usually pretty good at this. Here's what I'm having trouble with.

My app includes a Poll system built from scratch. Each question will run for one month. the month that the poll will run is kept in 2 columns in my table... runMonth and runYear.

What i'm having trouble doing is selecting the rows that don't match both the current runMonth and current runYear.

My Table...

id.............Question...........runMonth...........runYear
1..............QA...................1......................2007
2..............QB...................2......................2007
3..............QC...................3......................2007
4..............QD...................4......................2007 (current month and year)
5..............QE...................5......................2007
6..............QF...................6......................2007

I can simply get the question for the current month...



SELECT * FROM table WHERE runMonth = 4 AND runYear = 2007;
but if I try to get all others using


SELECT * FROM table WHERE runMonth != 4 AND runYear != 2007
I get an empty result set. As I should because there is nothing there that the runYear != 2007 doesn't knock out. The result set I am looking for is


id.............Question...........runMonth...........runYear
1..............QA...................1......................2007
2..............QB...................2......................2007
3..............QC...................3......................2007
*********************(remove runMonth4 and runYear 2007)
5..............QE...................5......................2007
6..............QF...................6......................2007

What am I missing?

View Replies !
Add Time Using A Select Query
Hello, how can I add, say, 2 hrs from a time in a database using a select query. I have searched the forums but cannot find an answer. Is it possible PHP Code:

 select 
date,
`time`                         as timetime
     , time_format(`time','%l:%i %p') as Printtime,
client,
address
from.......... 

View Replies !
Select Between Date And Time
I have field date and time respectively. I want to select date between (date1 and time1 > 17) and (date2 < 17)

I tried two ways but doesn't work, please see code below.
SELECT * from purchases_suppliers WHERE (date_invoice >= '2009/02/25' and time_invoice > 17) AND (date_invoice <= '2009/02/27' AND time_invoice < 17)

SELECT * from purchases_suppliers WHERE date_invoice between ('2009/02/25' ANd time_invoice > 17) AND ('2009/02/27' AND time_invoice < 17 )

View Replies !
Update And Select Same Time
Code:

UPDATE art SET art.art_writer = (SELECT writer.writer_name, art.art_author FROM writer, author WHERE art.art_author LIKE 'writer.writer_name')

Is this query syantex is ok ?

Where, art_writer is empty fild where I want to put correct value which is in writer table and it should similar to value in art_author filed.

View Replies !
SELECT With TIME INTERVAL
I have in my database a table with this structure:

id, latitude, longitude, speed, userid and Timestamp....

View Replies !
Select Statement Where Time <= 5min Ago
i tried many different MySQL fucntions and looked through the MySQL manual, and it didnt help me any. What i want to do is select all rows from a table where my time column(DATETIME) is less then or equal to 5 minutes ago from now().

View Replies !
Cron Job And Time Select Question
I am trying to figure out a select...where statement to use in a script running via cron job several times an hour.
example in plain english:cron job runs hourly, e.g. 12:50, 1:10, 1:30
need to select records where a datetime field is > 12:45
next hour I need to select where the datetime field is > 1:45
and so on....How do I calculate the time to use in my where statement?

View Replies !
Select Date And Time In Same Column
I have table called mytable and there I have column named time
example:
time
2006-07-10 10:28:06
2006-08-18 20:48:22
2006-09-15 12:11:41
2006-10-12 23:06:02

is there any possibles that I can make query example:
SELECT *FROM mytable WHERE date BETWEEN 2006-07-10 AND 2006-09-15 AND time
BETWEEN 10:28:06 AND 12:11:41

My point is can I make query where I first find between date and after that I make
query where I find between time when information is in the same column?

View Replies !
Select Records That Only Occur One Time
SELECT records that only occur one time.

I have a table with an ID field. I want to SELECT the records where the ID field only has one occurrence. If it appears in two or more rows I do not want to SELECT it.

View Replies !
Select Date Ignoring Time
Im using a datetime fields eg. "2006-08-07 16:01:09" and I want to select dates... eg. "select * from mytable where mydate="2006-08-07" ignoring the time.

View Replies !
Easy SELECT With OR Takes A Very Long Time
We've got a database with about 1000000 books. A query in the table
BOOKS for the TITLE 'java' is very fast. We have a fulltext index on
the column TITLE.

However, if we want to do a exact same query and include the rule that
the book with ISBN '0131016210' always should be included - then the
query take several seconds to finish:

SELECT * FROM C_BOOK WHERE MATCH(NAME) AGAINST ('java') AND (ISBN LIKE
'0%' OR ISBN LIKE '1%') OR ISBN = '0131016210'

ISBN is the PRIMARY KEY.

Is there anything I can do about this?

View Replies !
Datatype TIME - Select Statement Format
The table I have has two columns of ID and INTERVALS. The INTERVALS is datatype TIME. Whenever I do a select I always get the table back showing the time in the format HH:MM:SS like for 11am I get back 11:00:00. I only want HH:MM like 11:00. How do I achieve this? I have tried to limit to 2 decimal places but that has not worked so far. ...

View Replies !
Select Record In Time Range Not Working
$today=date('Ymd');

"SELECT * FROM data WHERE (startdate>='".$today."' AND stopdate <='".$today."'.....

View Replies !
How To Delete Rows In A Table Where Url Shows Only 1 Time In Whole Table
I don't know a whole lot about mysql, i need to fix some things in my db and what i described in the title is the first thing id like to do.

Now, I have a table which lists referring urls, clicks to them and the time. Everytime i get a hit from lets say url1.com it gets a new row with a time id (like 1218613809). I am not resetting this table since it has to track the incoming hits forever since the moment they start sending traffic.
But now the table starts getting the hickups now and then, it has about 850.000 records in it and it cant handle it anymore. I need to do a 'repair table' action and then it's good again, but it happens more and more often lately.

So first i want to delete the rows of the urls who have only sent me 1 click. These urls who sent me 1 click only have one row. When an url sent me 20 clicks, that url is in 20 rows in the table.

So I want to delete the rows of the table with the url's that only show once in the entire table. How do i do this?

View Replies !
SELECT With 1,000,000 ROWS
I have aproximately 1,000,000 rows and I would like to do some query. The
first one is to get the number of row so I do :

mysql> SELECT COUNT(*) FROM `Log`;
+----------+
| COUNT(*) |
+----------+
| 969129 |
+----------+
1 row in set (0.00 sec)

mysql> SELECT COUNT(*) AS `Nb` FROM `Log` WHERE `ID` = 49;
+--------+
| Nb |
+--------+
| 969129 |
+--------+
1 row in set (1 min 20.99 sec)

But like you can see it, it take a long with the WHERE clause. I use Pentium
III at 650 Mhz with 48 Mb of ram. I think that the probleme come from the
computer but I'm not shure (I need more RAM ?).

View Replies !
Num Of Rows In SELECT
I am just wondering if it is possible in one query to select some rows using WHERE and LIMIT clausule, and get the number of rows I would get when i dont use LIMIT.

if I have
SELECT * FROM table WHERE column1='something' LIMIT 10, 15;
i know it is 15 rows selected. But i need to know how many rows are in:
SELECT * FROM table WHERE column1='something';

I know, there is a way.. just to do both SELECTs.. and retrieve data from the first one, and num of rows from the another one..
But I just dont want to make two SELECTs if there is maybe some solution how can i do it in one query.it for page with forum where i want to show users how many threads are in database, but at one page i need to show just 15 threads...

View Replies !
Select All Rows
I'm trying to figure out how to select all rows created during the current month. So, for instance, now I would want it to return ALL rows created during May. Next month, it should show every row created in June 2005. In my database, I have the field "date," where a date is stored in mm/dd/yy syntax, and I also have a "timestamp" field, which is created using PHP's time() function.

View Replies !

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