【问题标题】:Search all record where the document date is below the selected date from date picker从日期选择器中搜索文档日期低于所选日期的所有记录
【发布时间】:2016-11-15 04:09:54
【问题描述】:

我想获取并显示文档日期低于所选日期的所有记录。假设我从日期选择器 2016/09/28 中选择一个日期,这意味着它将显示所选日期以下的所有记录。

SELECT * From `bill` WHERE bill_date <= '".$from."'

【问题讨论】:

    标签: php html mysql sql date


    【解决方案1】:

    试试这样的:

    $selDate = date('Y-m-d', strtotime($from));
    // convert the selected date to mysql date format
    
    SELECT * From `bill` WHERE bill_date <= '".$selDate."';
    

    注意:如果 bill_date 是 datetime 类型,则使用 date() 函数提取日期部分,然后将条件放在上面。

    【讨论】:

    • bill_date 类型是日期而不是日期时间。我尝试了您提供的示例,但它仍然显示 2016/09/15 记录,其中 bill_date
    • 解决了.. 使用内部连接时的查询问题
    • 请解释一下?
    • 我的查询出了点问题,我使用了很多表的内部联接,它导致重复,我从查询中删除了一些不相关的表。
    猜你喜欢
    • 1970-01-01
    • 2010-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-24
    • 1970-01-01
    • 2016-12-13
    • 1970-01-01
    相关资源
    最近更新 更多