
[英]SQL Start date is current day then end date is 1 month ago even if its not from the first to the last of the month
[英]Filter by date in SQL Server table from the first day three months ago
我有一个表,其中applicationdate
作为其列之一。 我需要从今天过滤到过去 3 个月而不是仅仅三个月前,也就是说,如果今天是9/26/2022
,我想从6/1/2022
过滤,而不是6/26/2022
.
这段代码从今天开始拉三个月前
SELECT *
FROM table
WHERE applicationdate >= DATEADD(month, -3, applicationdate)
结果到 2022 年 6 月 26 日。 我感兴趣到 2022 年 6 月 1 日
根据一些谷歌搜索,我可以使用trunc()
, datetrunc()
或date_trunc()
来获得三个月前的第一天,但他们每个人都会抛出一个 function 错误说:
'function' 不是可识别的内置 function 名称。
如何过滤到三个月前的第一个?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.