select date column greater then specific

风格不统一 提交于 2019-12-13 02:07:35

问题


I have the following criteria in where clause:

cat_product.datetime > '2012-09-18 11:24:54'

In the result:

18.09.2012 11:24:54
18.09.2012 11:34:51
18.09.2012 12:07:12

The problem in that the result contain 18.09.2012 11:24:54. Why? In the criteria write > operator not >=.


回答1:


Problem with milliseconds. Needs to convert to a format which do not have miliseconds. Such as :

SELECT CONVERT(VARCHAR,GETDATE(),120)

For you, it should be something like:

CONVERT(VARCHAR, cat_product.datetime,120) > '2012-09-18 11:24:54'



回答2:


Try this:

cat_product.datetime > fmtdate('yyyy-mm-dd hh:nn:ss','2012-09-18 11:24:54')



来源:https://stackoverflow.com/questions/12492960/select-date-column-greater-then-specific

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!