我有数据表1
file Startdate
A 2020-05-01
B 2020-06-01
今天是2020-06-01,我可以使用select和where startdate='2020-06-01'
但我尝试了这个查询,却没有得到2020-06-01
select file from table1
where
startdate >= dateadd(month, -1, datefromparts(year(getdate()), month(getdate()), 1))
and startdate < datefromparts(year(getdate()), month(getdate()), 1)
请纠正我。谢谢您
3条答案
按热度按时间p5fdfcr11#
这样写和理解起来就容易多了。mysql数据库
数据库
1aaf6o9v2#
你在找什么
这会回来的
更新:
我的意思不仅仅是2020-06-01,如果我加上2020-06-02,那么应该会得到2020-06-01和2020-06-02的两个记录
pxy2qtax3#