【问题标题】:How to get the rest hours of the current week in PostegreSQL如何在 PostgreSQL 中获取本周的休息时间
【发布时间】:2016-10-10 09:23:11
【问题描述】:

我想知道从现在起在 PostegreSQL 中一周内还剩多少小时

【问题讨论】:

  • 请描述更多。
  • 我想根据 avg_hours_sales 预测我本周将获得多少销售额,我的公式如下所示:sales_now_this_week + (avg_sales_per_hour * rest_hours_this_week)

标签: sql postgresql date datepart


【解决方案1】:

您是否正在寻找类似的东西:

WITH t(i) AS
     (SELECT age(
                date_trunc('week', current_timestamp)
                   + '1 week'::interval,
                current_timestamp
             )
     )
SELECT extract('days' FROM i) * 24
     + extract('hours' FROM i)
FROM t;

【讨论】:

    猜你喜欢
    • 2022-01-24
    • 2021-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多