Operand type clash: date is incompatible with int in dateadd

C.J.

The following query works:

select dateadd(m, -5, getdate() - datepart(d, getdate()) + 1)

But when I tried to replace the getdate() with a specific date, example below:

select dateadd(m, -5, (convert(DATE,'2017-01-04') - (datepart(d, getdate()) + 1)))

I get the error saying Operand type clash: date is incompatible with int

What did I do wrong?

M.Ali

It is because GETDATE() returns DATETIME datatype ,You Can do -1 or +1 with Datetime values but not with Date values.

If you just changed your query a little bit , convert to datetime instead of Date it will work fine.

select dateadd(   m
               , -5
               , (convert(DATETIME,'2017-01-04') - (datepart(d, getdate()) + 1))) 

                              ^-- Datetime instead of Date

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Tsql Operand type clash: date is incompatible with int

From Dev

Sql Server Operand type clash: date is incompatible with int

From Dev

Sql Server Operand type clash: date is incompatible with int

From Dev

c# Operand type clash: date is incompatible with int

From Dev

Stored Procedure Operand type clash: date is incompatible with int

From Dev

Operand type clash: text is incompatible with uniqueidentifier

From Dev

Operand type clash: text is incompatible with uniqueidentifier

From Dev

Operand type clash: bigint is incompatible with time

From Dev

Operand type clash geography is incompatible with float

From Dev

Operand type clash: nvarchar is incompatible with Type_WP_Days

From Dev

Operand type clash: nvarchar is incompatible with Type_WP_Days

From Dev

Getting error:Operand type clash: nvarchar is incompatible with image

From Dev

NHibernate component mapping: Operand type clash: bigint is incompatible with time

From Dev

Incompatible operand types Die and Int

From Dev

Table type parameter in a stored procedure cause operand type clash error

From Dev

Incompatible operand types between K and int Java

From Dev

incompatible operand types r.integer and int

From Dev

Argument of type "int" is incompatible with parameter of type "int *"

From Dev

Operand Data Type Clash when executing sp_help_job via VB.Net

From Dev

Error: operand types are incompatible ("int" and "const char*") c++

From Dev

TypeError: unsupported operand type(s) for +=: 'int' and 'list'

From Dev

unsupported operand type(s) for +: 'NoneType' and 'int'

From Dev

Unsupported operand type(s) for +: 'int' and 'str'

From Dev

TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

From Dev

Unsupported operand type(s) for /: 'unicode' and 'int'

From Dev

TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

From Dev

TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

From Dev

TypeError: unsupported operand type(s) for |: 'int' and 'str'

From Dev

unsupported operand type(s) for +: 'int' and 'tuple'

Related Related

  1. 1

    Tsql Operand type clash: date is incompatible with int

  2. 2

    Sql Server Operand type clash: date is incompatible with int

  3. 3

    Sql Server Operand type clash: date is incompatible with int

  4. 4

    c# Operand type clash: date is incompatible with int

  5. 5

    Stored Procedure Operand type clash: date is incompatible with int

  6. 6

    Operand type clash: text is incompatible with uniqueidentifier

  7. 7

    Operand type clash: text is incompatible with uniqueidentifier

  8. 8

    Operand type clash: bigint is incompatible with time

  9. 9

    Operand type clash geography is incompatible with float

  10. 10

    Operand type clash: nvarchar is incompatible with Type_WP_Days

  11. 11

    Operand type clash: nvarchar is incompatible with Type_WP_Days

  12. 12

    Getting error:Operand type clash: nvarchar is incompatible with image

  13. 13

    NHibernate component mapping: Operand type clash: bigint is incompatible with time

  14. 14

    Incompatible operand types Die and Int

  15. 15

    Table type parameter in a stored procedure cause operand type clash error

  16. 16

    Incompatible operand types between K and int Java

  17. 17

    incompatible operand types r.integer and int

  18. 18

    Argument of type "int" is incompatible with parameter of type "int *"

  19. 19

    Operand Data Type Clash when executing sp_help_job via VB.Net

  20. 20

    Error: operand types are incompatible ("int" and "const char*") c++

  21. 21

    TypeError: unsupported operand type(s) for +=: 'int' and 'list'

  22. 22

    unsupported operand type(s) for +: 'NoneType' and 'int'

  23. 23

    Unsupported operand type(s) for +: 'int' and 'str'

  24. 24

    TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

  25. 25

    Unsupported operand type(s) for /: 'unicode' and 'int'

  26. 26

    TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

  27. 27

    TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

  28. 28

    TypeError: unsupported operand type(s) for |: 'int' and 'str'

  29. 29

    unsupported operand type(s) for +: 'int' and 'tuple'

HotTag

Archive