Sqlite Filter as error in return date with strftime function

1

Hello, I have the error in the following code

SELECT L.*, C.DESCRICAO AS CATEGORIA , CASE WHEN L.TIPO_LANCAMENTOS = 'C' THEN 0 ELSE 1 END AS ICONE
FROM LANCAMENTOS L JOIN CATEGORIAS C ON(C.CODIGO = L.COD_CATEGORIA)
WHERE strftime('%m', L.DATA) = '10'
AND strftime('%Y', L.DATA) = '2016'

The select works fine I've already rounded this query and it's correct the problem starts exactly in the where it's of paramount importance this condition for my filter. I believe that with this code was to be bringing all the records of month 10 and year 2016, but nothing happens. I tried to make that change.

SELECT L.*, C.DESCRICAO AS CATEGORIA , CASE WHEN L.TIPO_LANCAMENTOS = 'C' THEN 0 ELSE 1 END AS ICONE
FROM LANCAMENTOS L JOIN CATEGORIAS C ON(C.CODIGO = L.COD_CATEGORIA)
WHERE strftime('%m', L.DATA = '10')
AND strftime('%Y', L.DATA = '2016')

I changed the position of the parentheses, but it does not run the filter and ends up bringing all records from the table every month and every year and that's not what I want. Thanks in advance for your help.

    
asked by anonymous 17.11.2016 / 18:19

1 answer

1

Do this:

SELECT L.*, C.DESCRICAO AS CATEGORIA , CASE WHEN L.TIPO_LANCAMENTOS = 'C' THEN 0 ELSE 1 END AS ICONE
FROM LANCAMENTOS L JOIN CATEGORIAS C ON(C.CODIGO = L.COD_CATEGORIA)
WHERE strftime('%m-%Y', L.DATA ) = '10-2016'
    
17.11.2016 / 18:44