Assuming ACTION_DATE is of the DATE data type then a simple method is to just use DATE literals:
SELECT DSC_REF,
EMP_NO,
EMP_NAME,
ACTION_DATE
from DSC_UPLOAD
WHERE ACTION_DATE >= DATE '2018-02-01'
AND ACTION_DATE < DATE '2018-04-01'
If it is a string (why?) then:
SELECT DSC_REF,
EMP_NO,
EMP_NAME,
ACTION_DATE
from DSC_UPLOAD
WHERE TO_DATE( ACTION_DATE, 'dd/mm/yyyy' ) >= DATE '2018-02-01'
AND TO_DATE( ACTION_DATE, 'dd/mm/yyyy' ) < DATE '2018-04-01'
is there any way to retrieve data only using month and year without mentioning date
You can do:
WHERE EXTRACT( MONTH FROM TO_DATE( ACTION_DATE, 'dd/mm/yyyy' ) ) IN ( 2, 3 )
AND EXTRACT( YEAR FROM TO_DATE( ACTION_DATE, 'dd/mm/yyyy' ) ) = 2018
Regarding your query, if ACTION_DATE is a DATE data type then:
to_date(ACTION_DATE,'dd/mm/yyyy')
Is a bad idea. TO_DATE( date_string [, format_string [, nls_string] ] ) has a signature that takes between 1 and 3 string arguments. Oracle will try to be helpful and implicitly convert your date to a string using the NLS_DATE_FORMAT session parameter as the format model and you end up with a query that is effectively:
TO_DATE(
TO_CHAR(
ACTION_DATE,
(
SELECT VALUE
FROM NLS_SESSION_PARAMETERS
WHERE PARAMETER = 'NLS_DATE_FORMAT'
)
),
'dd/mm/yyyy'
)
If the NLS_DATE_FORMAT does not match dd/mm/yyyy then you will get an exception - and the NLS_DATE_FORMAT is a session parameter so each user can modify it and it may not be consistent between users or even user sessions.
varcharcolumn. That is a terrible idea.EXTRACT()function returns a NUMBER not a CHAR.