Blob
Blob

Reputation: 541

SQL statement not working - "Operand type clash: date is incompatible with int'

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 clash: 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.

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

Please could i be advised where i am going wrong?

Thanks.

Upvotes: 3

Views: 27460

Answers (3)

Sunil Kumar B M
Sunil Kumar B M

Reputation: 2795

Use this

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

Date must be in yyyy-mm-dd format

Upvotes: 0

Nanhydrin
Nanhydrin

Reputation: 4472

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')

Upvotes: 8

penartur
penartur

Reputation: 9912

(Date = 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.

Upvotes: 1

Related Questions