gpt4 book ai didi

php - 我们如何将存储为 varchar 的日期转换为日期

转载 作者:行者123 更新时间:2023-11-30 22:00:59 27 4
gpt4 key购买 nike

这里我的日期值存储在 varchar 中,我想在日期之间搜索时获得结果这是我的代码,请看一下

public function get_report($from1,$to1)
{
$from=DATE($from1);
$to=DATE($to1);
$this->db->order_by('customer_account_id','desc');
$this->db->where('Date(`date`) >= ',$from);
$this->db->where('Date(`date`) <= ',$to);
return $this->db->get('customer_accounts');


}

我的 date_format 是这样的 31-01-2017 并且当我这样使用我的代码时,结果没有获得

最佳答案

MySQL date 函数需要 'YYYY-MM-DD' 格式的 dates。如果您将存储在 varchar 列中的日期值更改为该格式,那么您应该会得到所需的结果。如果您将 varchar 列转换为 date 会更好,因为当您从表中选择数据时这会更快。

关于php - 我们如何将存储为 varchar 的日期转换为日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43369174/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com