【发布时间】:2019-03-14 23:22:38
【问题描述】:
我有一个名为 Billing 的表格,其中包含以下列
id| resource_name | start_date | end_date | total_amount
此表填充了具有不同 start_date 和 end_dates 的不同资源的数据。我需要从表中检索数据。
样本记录
id| resource_name | start_date | end_date | total_amount
1 | abc | 2018-09-15 03:00:00 | 2018-09-15 04:00:00 | 20
如果我编写这样的查询,它将返回上述结果
select * from billing where start_date >= '2018-09-15 03:00:00' and end_date <= '2018-09-15 04:00:00'
但下面没有
select * from billing where start_date >= '2018-09-15 03:00:00' and end_date <= '2018-09-15 03:30:00'
有什么方法可以找回相同的 .我正在使用 Django ORM 来做同样的事情
【问题讨论】:
-
记录将如何返回时间为 4 并且您给出 3.30 的地方,所以它不会匹配,
-
@Exprator 是的,我知道。我正在检查是否有任何功能可以帮助我做到这一点。而不是使用
-
不,你不能用任何给出 3.30 的函数来做到这一点,其中 4 更大
标签: django postgresql django-models django-orm