SQL语句不工作——“操作数类型冲突:日期与int不兼容”

时间:2022-03-19 09:26:38

I have a table which i am trying to return the Time and Productno columns for a specific date. When i try the following SQL command it returns the error: "Operand type *: date is incompatible with int'. I have research on forums and this is the way most people have been achieving a similar thing which is getting me puzzled. The data types for the following fields are as follows: Date: date. Time: time(7). Productno: int.

我有一个表,我试图返回特定日期的时间和Productno列。当我尝试使用下面的SQL命令时,它会返回错误:“操作数类型*: date与int不兼容”。我在论坛上做过研究,这是大多数人实现类似的事情的方式,这让我感到困惑。以下字段的数据类型如下:日期:日期。时间:时间(7)。Productno:int。

SELECT        Date, Time, Productno
FROM            Products
WHERE        (Date = 07 / 09 / 2008)

Please could i be advised where i am going wrong?

请告诉我哪里出错了,好吗?

Thanks.

谢谢。

3 个解决方案

#1


5  

Your date format is incorrect, it needs to be in quotes and rearranged slightly.

您的日期格式不正确,需要加引号,并稍作调整。

WHERE        (Date = 'Year-Month-day')

or rather

或者更确切地说

WHERE        (Date = '2008-09-07')

#2


1  

(Date = 07 / 09 / 2008)

(日期= 07 / 09 / 2008)

Here you dividing (int)7 by (int)9 and then by (int)2008. So 07 / 09 / 2008 is an integer result of some calculations. In order to pass the date instead, you should put it into quotes.

这里你要除以(int)7除以(int)9,然后除以(int)2008。所以07 / 09 / 2008是一些计算的整数结果。为了传递日期,你应该把它放在引号里。

#3


0  

Use this

使用这个

SELECT Date, Time, Production
FROM Products
WHERE Date="2008-09-07"

Date must be in yyyy-mm-dd format

日期必须是yyyy-mm-dd格式

#1


5  

Your date format is incorrect, it needs to be in quotes and rearranged slightly.

您的日期格式不正确,需要加引号,并稍作调整。

WHERE        (Date = 'Year-Month-day')

or rather

或者更确切地说

WHERE        (Date = '2008-09-07')

#2


1  

(Date = 07 / 09 / 2008)

(日期= 07 / 09 / 2008)

Here you dividing (int)7 by (int)9 and then by (int)2008. So 07 / 09 / 2008 is an integer result of some calculations. In order to pass the date instead, you should put it into quotes.

这里你要除以(int)7除以(int)9,然后除以(int)2008。所以07 / 09 / 2008是一些计算的整数结果。为了传递日期,你应该把它放在引号里。

#3


0  

Use this

使用这个

SELECT Date, Time, Production
FROM Products
WHERE Date="2008-09-07"

Date must be in yyyy-mm-dd format

日期必须是yyyy-mm-dd格式