Selecting Dates

Selecting Dates

am 01.02.2010 02:35:01 von Jason ML

Hi All,

Switching from Oracle to MySQL, I seem to be having some difficulty =
selecting dates using between or even where >=3D and <=3D like:

SELECT * FROM orders WHERE order_date BETWEEN=3D'2010-01-01' AND =
'2010-01-30' ORDER BY order_date;

or

SELECT * FROM orders WHERE order_date =3D>'2010-01-01' AND <=3D =
'2010-01-30' ORDER BY order_date;

Neither of these work.

What am I missing?

-ML

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: Selecting Dates

am 01.02.2010 15:23:32 von Lucky Wijaya

--0-1849690057-1265034212=:93317
Content-Type: text/plain; charset=us-ascii

Just trying to help.

SELECT * FROM orders WHERE order_date BETWEEN '2010-01-01' AND
'2010-01-30' ORDER BY order_date;

or

SELECT * FROM orders
WHERE order_date >= '2010-01-01' AND <= '2010-01-30' ORDER BY
order_date;





________________________________
From: ML
To: mysql@lists.mysql.com
Sent: Mon, February 1, 2010 8:35:01 AM
Subject: Selecting Dates

Hi All,

Switching from Oracle to MySQL, I seem to be having some difficulty selecting dates using between or even where >= and <= like:

SELECT * FROM orders WHERE order_date BETWEEN='2010-01-01' AND '2010-01-30' ORDER BY order_date;

or

SELECT * FROM orders WHERE order_date =>'2010-01-01' AND <= '2010-01-30' ORDER BY order_date;

Neither of these work.

What am I missing?

-ML

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=luckyx_cool_boy@yahoo.com



--0-1849690057-1265034212=:93317--

Re: Selecting Dates

am 01.02.2010 15:25:41 von sureshkumarilu

SGkNCldoYXQgaXMgdGhlIGRhdGF0eXBlIG9mIHRoZSBjb2x1bW4gb3JkZXJf ZGF0ZS4gR2l2ZSB0
aGUgZnVsbCBmb3JtIG9mIHRoZSBkYXRlIGZvciB0aGUgYmV0d2VlbiBjb25k aXRpb24uDQoNClRo
YW5rc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ed30e92b047e8adc38
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Shouldn't it be:
SELECT * FROM orders WHERE order_date >=3D '2010-01-01' AND order_date <=3D
'2010-01-30' ORDER BY order_date;

?

change the "=3D>" and repeat the column_name. Datetime should be datetime =
or
timestamp;

On Mon, Feb 1, 2010 at 8:25 AM, wrote:

> Hi
> What is the datatype of the column order_date. Give the full form of the
> date for the between condition.
>
> Thanks
> Suresh Kuna
> MySQL DBA
> ------Original Message------
> From: ML
> To: mysql@lists.mysql.com
> Subject: Selecting Dates
> Sent: Feb 1, 2010 7:05 AM
>
> Hi All,
>
> Switching from Oracle to MySQL, I seem to be having some difficulty
> selecting dates using between or even where >=3D and <=3D like:
>
> SELECT * FROM orders WHERE order_date BETWEEN=3D'2010-01-01' AND '2010-01=
-30'
> ORDER BY order_date;
>
> or
>
> SELECT * FROM orders WHERE order_date =3D>'2010-01-01' AND <=3D '2010-01-=
30'
> ORDER BY order_date;
>
> Neither of these work.
>
> What am I missing?
>
> -ML
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=3Dsureshkumarilu@gmail.co m
>
>
>
> Sent from BlackBerry=AE on Airtel




--=20
Jim Lyons
Web developer / Database administrator
http://www.weblyons.com

--0016e6d778ed30e92b047e8adc38--

Re: Selecting Dates

am 01.02.2010 16:13:03 von Jason ML

Jim,

> Shouldn't it be:
> SELECT * FROM orders WHERE order_date >=3D '2010-01-01' AND order_date =
<=3D '2010-01-30' ORDER BY order_date;
>=20
> ?
>=20
> change the "=3D>" and repeat the column_name. Datetime should be =
datetime or timestamp;

Spot on. Thank you for the clarification, obviously a syntax mistake on =
my part.

-ML=

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: Selecting Dates

am 04.02.2010 01:52:14 von Paul DuBois

On Jan 31, 2010, at 7:35 PM, ML wrote:

> Hi All,
>
> Switching from Oracle to MySQL, I seem to be having some difficulty selecting dates using between or even where >= and <= like:
>
> SELECT * FROM orders WHERE order_date BETWEEN='2010-01-01' AND '2010-01-30' ORDER BY order_date;

No "=" after BETWEEN.

>
> or
>
> SELECT * FROM orders WHERE order_date =>'2010-01-01' AND <= '2010-01-30' ORDER BY order_date;

Need "order_date <=", not just "<=".

>
> Neither of these work.
>
> What am I missing?
>
> -ML

--
Paul DuBois
Sun Microsystems / MySQL Documentation Team
Madison, Wisconsin, USA
www.mysql.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org