【发布时间】:2020-05-09 18:17:16
【问题描述】:
我正在尝试计算从第一天到昨天的当前月份的天数,而无需手动更改计数。原SQL如下:
select order_id
from orders
where date > dateadd(-23 to current_date) and date < 'today'
所需的代码类似于
select order_id
from orders
where date > dateadd(datediff(day,firstdayofthemonth,current_date) to current_date) and date < 'today'
感谢任何帮助
【问题讨论】:
-
我注意到这与您之前的问题非常相似:Get last month data from first day until last day in Firebird
-
您询问“从第 1 天到昨天的当前月份的天数”。 只是为了澄清一下,当查询在 1 日运行时,您希望发生什么一个月?那么“昨天”将不再是“当前月份”。你想要零结果吗?您想要上个月的全部内容吗?
标签: sql date datetime select firebird