【问题标题】:Why does daterange function not exist?为什么 daterange 函数不存在?
【发布时间】:2019-05-17 01:19:55
【问题描述】:

我在我的 C# (Net Core 2.2 + npgsql 4.0.6) 中尝试了以下 postgresql 命令:

string _sql = "select * from user_branch_rotation where daterange(start_date, end_date,'[)') && daterange('2019-02-10','2020-05-11') and users_pid=4 and branch_pid=2"

var _q = await _conn.QueryAsync(_sql , new { });

但它会返回

"函数daterange(时间戳不带时区,时间戳不带 时区)不存在”

注意。我在 pgadmin 上尝试了上面的 postgresql 命令,它工作正常。

有人经历过吗?

【问题讨论】:

  • 可能是该函数存在但被错误调用 - 检查参数..?
  • 尝试在 postgress 中直接执行该销售。确保你调用了正确的数据库

标签: c# datetime npgsql


【解决方案1】:

只想分享,

使用 tsrange 解决了这个问题:

    select * from user_branch_rotation where (tsrange(start_date,end_date,'[]') 
    &&  (tsrange('2019-02-10','2020-05-11','[]') and users_pid=4 and branch_pid=2

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-25
    • 2016-02-15
    • 2011-12-18
    • 1970-01-01
    相关资源
    最近更新 更多