-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()
,並給它一個去
似乎很大。什麼東西阻止你? –
尋找解決方案..如何做到這一點 –