日期过滤不起作用 [英] Filter on Date not working
问题描述
我正在插入表格,工作正常。
但是我想删除1999年之前的数据。
I am doing a insert into a table, which is working fine. But I want to remove data that is prior the year 1999.
这就是我在查询中所做的:
This is what I am doing in the query:
SELECT Transaction_No, Item_no, Item_description, Date, Sales
FROM Inventory_Table
WHERE
[Date] > '1999-01-01 00:00:00.000'
但它会继续在新数据中显示以前的数据
But it keeps showing prior data in the new table.
我尝试从日期中删除 00:00:00.000,但仍然无法正常工作。
I have tried removing the '00:00:00.000' from date but still not working.
这里似乎是什么问题?
What seems to be the issue here?
谢谢您的帮助!
编辑:
日期字段是[Datetime]不为空,
The Date field is a [Datetime] not null,
我的查询返回:
Transaction_No Item_No Item_Description Date Sales
001 019238 Baseball 1900-01-01 00:00:00.000 100
002 014952 Basketball 1900-01-01 00:00:00.000 250
-----------------------------------------------------------------------------------
254 012459 Gloves 2005-05-05 00:00:00.000 550
255 014563 Pants 2005-05-05 00:00:00.000 250
I想要删除1999年之前的所有数据。
在此示例中是事务001和002。
I want to get rid of all data prior to the year 1999. That is transactions 001 and 002 in this example.
也尝试了没有任何帮助:
Have also tried without no help:
SELECT Transaction_No, Item_no, Item_description, Date, Sales
FROM Inventory_Table
WHERE
Datepart(year,[Date]) > 1999
推荐答案
我在做插入表格,效果很好。但是我想
删除1999年之前的数据。
I am doing a insert into a table, which is working fine. But I want to remove data that is prior the year 1999.
不确定我正确理解了这一点,但是插入添加了行到桌子上。如果要删除行,则应使用删除。
Not sure I understand this correctly but insert adds rows to a table. If you want to remove rows you should use delete.
delete from Inventory_Table
where [Date] < '1999-01-01 00:00:00.000'
这篇关于日期过滤不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!