Skip to content
Advertisement

How do you write a sql statement that creates a new column for a date value and then queries it in the WHERE clause

I have written a sql statement as so:

But it is returning

Operand type clash: date is incompatible with int

PaymentDate is a Date format in the database – but do i have to format the new date column ‘NewPaymentDate’ into a date format and if so, how do i do this?

Thanks

Advertisement

Answer

This looks like SQL Server syntax. Why do you need to pass in the current date? Just use the database date:

If you want to pass a value in, learn to use parameters to pass values in — the syntax varies depending on the API you are using for accessing the database.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement