|
Posted by NC on 03/13/06 18:13
Jay wrote:
>
> MySQL Database has DateTime Values (Example: 2/9/2006 3:30:06PM)
Er, no. A MySQL database has a DateTime value that looks like this:
2006-02-09 15:30:06
You can think of it as text, and when you sort it as text, it sorts in
a correct chronological order...
> I would like to be able to perform the following queries:
>
> 1: specific date (show all records on that date)
SELECT * FROM mytable WHERE myDTfield = '2006-02-09%';
The addition of % mask will ensure that all records dated Feb. 9, 2006
are shown.
Alternetively, you could try:
SELECT * FROM mytable
WHERE
MONTH(myDTfield) = 2
AND
DAY(myDTfield) = 9;
> 2. range of dates (show all records in between 2 dates. example: form
> 1/1/2006 to 1/3/2006)
SELECT * FROM mytable
WHERE
myDTfield >= '2006-01-01 00:00:00'
AND
myDTfield <= '2006-01-03 23:59:59';
Cheers,
NC
Navigation:
[Reply to this message]
|