-4
我有两个表格A1和A2。 表A1有列转移索引,日期和金额,A2表有列转移索引,名称和年龄。SQL查询找到数据
1.如何找到当月的shift-index数据。如果我选择shift-index 6,则应该填充6之前的数据。 移位指数表示日期
我有两个表格A1和A2。 表A1有列转移索引,日期和金额,A2表有列转移索引,名称和年龄。SQL查询找到数据
1.如何找到当月的shift-index数据。如果我选择shift-index 6,则应该填充6之前的数据。 移位指数表示日期
我想这你想要做什么:
where datecol >= dateadd(day, 1 - day(getdate()), cast(getdate() as date) and
datecol < cast(getdate() as date)
这将返回所有行日期之间的第一当月和昨天的。在本月的第一天,它不返回任何行。
你也可以做这样的事情
select * from YourTable
where YourDateColumn between
DATEADD(month, DATEDIFF(month, 0, getDate()), 0) and getDate() - 1
只需用日期值替换getDate()
,并给它一个去
似乎很大。什么东西阻止你? –
寻找解决方案..如何做到这一点 –