我在我们的数据库中使用日期范围的问题。有机格式是datetime“yyyy-mm-dd 00:00:00.000”。我试图与这几个方面的工作,我没有任何成功,这些方法是:何处子句为日期时间格式不合作
有机如上文所述:
Select I.InvoiceDate .... Where I.InvoiceDate >= '2017-01-01 00:00:00.000'
,并转换到MM/DD/YYY在选择与where子句为:
Select Convert(Char(10),I.InvoiceDate,101) as 'InvDt' ... Where Year(Convert(Char(10),I.InvoiceDate,101)) >= '2017'
另外使用有机字段名称,而不是用于where子句的转换:
Select Convert(Char(10),I.InvoiceDate,101) as 'InvDt' ... Where I.InvoiceDate >= '10/01/2017'
最后,我还尝试在select和/或where子句中使用合适的年/月标签挑选年份和/或月份。
在每种情况下相同的结果制作: Results I get AND the organic datetime format before converting to mm/dd/yyyy
感谢您的帮助好人。
什么是你的问题? –
如何根据日期获取where子句以指定过滤器。 – Miskondukt
您正在使用哪个[DBMS](https://en.wikipedia.org/wiki/DBMS)产品? “_SQL_”只是一种查询语言,而不是特定数据库产品的名称。 –