selecting a date in a date range

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
niche1
Forum Newbie
Posts: 3
Joined: Fri Oct 01, 2010 2:11 pm

selecting a date in a date range

Post by niche1 »

This works:
$result = mysql_query("SELECT * FROM plan WHERE begin BETWEEN '2010-09-01' AND '2010-09-30'") or die(mysql_error());

I need some version of this to work where begin and end are currently timestamped columns in my table:
$result = mysql_query("SELECT * FROM plan WHERE date("Y-m-d") BETWEEN begin AND end") or die(mysql_error());

What's the correct form? I haven't been able to tease it out of the documentation.
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: selecting a date in a date range

Post by DigitalMind »

curdate() ?
niche1
Forum Newbie
Posts: 3
Joined: Fri Oct 01, 2010 2:11 pm

Re: selecting a date in a date range

Post by niche1 »

You're close. MYSQL Date functions.

Thanks,

Niche1
Post Reply