I have this value in my database 101101-2017-06-000
It is value for column lddap_no
I want to select value with year equal to current year and current month my query is
SELECT lddap_no FROM lddap WHERE YEAR(lddap_no) = '2017' AND MONTH(lddap_no) = '06' ORDER BY sys_id DESC LIMIT 1
I used YEAR() and MONTH() respectively but it didnt work I get no result even if I have one entry.
How to correctly compare year and month from a column value that is not formatted date.
UPDATE
Used WHERE YEAR(substring(lddap_no,7,10)) = '2017' AND MONTH(substring(lddap_no,12,13)) = '06'
Still same no result found
tried using this
WHERE YEAR(SUBSTRING(CAST(lddap_no AS VARCHAR(100)), 7, 10)) = '2017' AND MONTH(SUBSTRING(CAST(lddap_no AS VARCHAR(100)), 12, 13)) = '06'