开发者

Retrieving dates that fall within two specified dates

I am storing the start and end date of a users holiday period in a MySQL table.

I need to enable the ability for administrators to run reports where they specify two dates and all users who's start date or end date fall in between the two specified dates are 开发者_JS百科retrieved from the database.

Has anyone done anything similar, or know of a good method of doing this?


use mysql's between operator


"SELECT * FROM table WHERE vac_start_date <= " . $search_end_date . " AND vac_end_date >= " . $search_start_date;

That should do it for you.


if you want between two dates you can do:

`date` >= '$from' AND `date` <= '$to'

in the WHERE statement of the msql

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜