Mysql Select question
Moderator: General Moderators
Mysql Select question
I want to select the rows where the first part of my datetime column is equal to the first part of a datetime variable (php).
Assuming this is the datetime in the database:
2005-01-19 21:00:00
I want to select that row as well if I search for this datetime:
2005-01-19 20:14:00
So the date characters should be exact the same. The time characters don't matter.
How can I do this?
I'm aware that I could have used only 'date' as my field type, but that would not be compatible with other code so I chose for datetime.
// SELECT * FROM shows WHERE datetime = '$datetime';
Assuming this is the datetime in the database:
2005-01-19 21:00:00
I want to select that row as well if I search for this datetime:
2005-01-19 20:14:00
So the date characters should be exact the same. The time characters don't matter.
How can I do this?
I'm aware that I could have used only 'date' as my field type, but that would not be compatible with other code so I chose for datetime.
// SELECT * FROM shows WHERE datetime = '$datetime';
[mysql_man]date[/mysql_man]
Code: Select all
select * from shows where date(datetime) = '$datetime'- protokol
- Forum Contributor
- Posts: 353
- Joined: Fri Jun 21, 2002 7:00 pm
- Location: Cleveland, OH
- Contact:
Try this to see what happened:
Code: Select all
<?php
echo mysql_error();
?>I've done it this way now:
Code: Select all
SELECT * FROM shows_shows WHERE datetime >= CURDATE() AND datetime='2005-01-01%' AND city='New York' AND country='USA' ORDER BY datetime ASC