I have a Date type in my MySQL table - I'm trying to do a query on all
rows within the last 30 days based on that Date field - I'm having
trouble figuring out how to form the query???
$php_SQL = "SELECT * FROM basics WHERE creation_date =
DATE_ADD(creation_date, INTERVAL -30 DAY)";
....doesn't do anything...
Thanks for any help. 6 7353
* Ralph Freshour <ra***@primemail.com>: I have a Date type in my MySQL table - I'm trying to do a query on all rows within the last 30 days based on that Date field - I'm having trouble figuring out how to form the query???
$php_SQL = "SELECT * FROM basics WHERE creation_date = DATE_ADD(creation_date, INTERVAL -30 DAY)";
...doesn't do anything...
I'm not too familiar with date calculations in MySQL, but perhaps changing
"creation_date =" to "creation_date >=" will solve your problem.
--
Benjamin D. Esham { http://bdesham.net bd*****@iname.com } AIM: bdesham 1 2 8
"Hmm... Earl Grey tea. Maybe that's how an old
bald guy can kick the Borg's collective ass."
-- bsharitt on Slashdot
No, that didn't work...any other thoughts???
On Sun, 31 Aug 2003 22:35:55 -0400, Benjamin Esham <bd*****@iname.com>
wrote: * Ralph Freshour <ra***@primemail.com>:
I have a Date type in my MySQL table - I'm trying to do a query on all rows within the last 30 days based on that Date field - I'm having trouble figuring out how to form the query???
$php_SQL = "SELECT * FROM basics WHERE creation_date = DATE_ADD(creation_date, INTERVAL -30 DAY)";
...doesn't do anything...
I'm not too familiar with date calculations in MySQL, but perhaps changing "creation_date =" to "creation_date >=" will solve your problem.
Ralph Freshour <ra***@primemail.com> wrote: I have a Date type in my MySQL table - I'm trying to do a query on all rows within the last 30 days based on that Date field - I'm having trouble figuring out how to form the query???
$php_SQL = "SELECT * FROM basics WHERE creation_date = DATE_ADD(creation_date, INTERVAL -30 DAY)";
You're searching rows which are exactly 30 days old - if you want all rows
within the last 30 days use:
SELECT * FROM basics WHERE creation_date > DATE_ADD(creation_date, INTERVAL
-30 DAY);
or:
SELECT * FROM basics WHERE creation_date > DATE_SUB(creation_date, INTERVAL
30 DAY);
HTH;
JOn
Hi Jon -
I tried both of your suggestions but neither worked - I doubled
checked my MySQL table col (field) data and all the dates are of Date
type and they are all in the month of August 2003 (varying days; 5th,
10th, etc.)
I don't have to tell the query to compare the last 30 days from today?
That's assumed in the query right?
On Mon, 01 Sep 2003 10:24:33 +0100, Jon Kraft <jo*@jonux.co.uk> wrote: Ralph Freshour <ra***@primemail.com> wrote:
I have a Date type in my MySQL table - I'm trying to do a query on all rows within the last 30 days based on that Date field - I'm having trouble figuring out how to form the query???
$php_SQL = "SELECT * FROM basics WHERE creation_date = DATE_ADD(creation_date, INTERVAL -30 DAY)";
You're searching rows which are exactly 30 days old - if you want all rows within the last 30 days use:
SELECT * FROM basics WHERE creation_date > DATE_ADD(creation_date, INTERVAL -30 DAY);
or:
SELECT * FROM basics WHERE creation_date > DATE_SUB(creation_date, INTERVAL 30 DAY);
HTH; JOn
Ralph Freshour <ra***@primemail.com> wrote: On Mon, 01 Sep 2003 10:24:33 +0100, Jon Kraft <jo*@jonux.co.uk> wrote:
Ralph Freshour <ra***@primemail.com> wrote:
I have a Date type in my MySQL table - I'm trying to do a query on all rows within the last 30 days based on that Date field - I'm having trouble figuring out how to form the query???
$php_SQL = "SELECT * FROM basics WHERE creation_date = DATE_ADD(creation_date, INTERVAL -30 DAY)";
You're searching rows which are exactly 30 days old - if you want all rows within the last 30 days use:
SELECT * FROM basics WHERE creation_date > DATE_ADD(creation_date, INTERVAL -30 DAY);
or:
SELECT * FROM basics WHERE creation_date > DATE_SUB(creation_date, INTERVAL 30 DAY);
I tried both of your suggestions but neither worked - I doubled checked my MySQL table col (field) data and all the dates are of Date type and they are all in the month of August 2003 (varying days; 5th, 10th, etc.)
I don't have to tell the query to compare the last 30 days from today? That's assumed in the query right?
Hi Ralph,
Sorry about that, you're absolutely right, you have to tell the period of
days from now, not from the datefield!
SELECT * FROM basics WHERE creation_date > DATE_SUB(NOW(), INTERVAL 30 DAY);
HTH;
JOn
On Sun, 31 Aug 2003 20:05:30 -0500, in message
<qk********************************@4ax.com>, the AI program named "Ralph
Freshour" <ra***@primemail.com> randomly printed: I have a Date type in my MySQL table - I'm trying to do a query on all rows within the last 30 days based on that Date field - I'm having trouble figuring out how to form the query???
$php_SQL = "SELECT * FROM basics WHERE creation_date = DATE_ADD(creation_date, INTERVAL -30 DAY)";
...doesn't do anything...
Thanks for any help.
Untested:
select * from basics where creation_date >=
date_add(now(), interval -30 day); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Albert Ahtenberg |
last post by:
Hi,
I have a database with a date field. And I would like to see the report
grouped by a ceratin month and year, how can I do that without multiple
queries?
Albert Ahtenberg
|
by: Dariusz |
last post by:
I am a beginner in PHP and MySQL, and am working through a book and various
online tutorials on PHP and MySQL and now stuck - installed everything on
"localhost" and it all works fine. My question...
|
by: Dan Lewis |
last post by:
I've imported a ms access database into a table in a mysql database.
The access database contains a field that holds date/time values in
'general date' format. These all show up at 01/01/1970 in...
|
by: hph |
last post by:
Please be gentle; I am a relative newbie for php/MySQL, and most of what
I am doing is based on being self-taught using someone else's
well-written code, and my own googling the answers to my...
|
by: ojorus |
last post by:
Hi!
My company make several flash-based games, and I use php to communicate with
mysql to provide highscore-lists.
My problem is this:
When I save a player's score in the mysql-table, I want to...
|
by: libsfan01 |
last post by:
how can i use regular expressions to ensure a mysql format date entry
in a text field?
thanks
marc
|
by: mantrid |
last post by:
Hello
Can anyone point me in the right direction for the way to read a text file a
line at a time and separate the fields on that line and use them as data in
an INSERT to add a record to a mysql...
|
by: Einstein30000 |
last post by:
Hi,
in one of my php-scripts is the following query (with an already open
db-connection):
$q = "INSERT INTO main (name, img, descr, from, size, format, cat,
host, link, date) VALUES ('$name',...
|
by: Atli |
last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users.
Anyone should be able to get...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |