I have a date variable as 24-dec-08. I want only the 08 component from it.
How do I do it in a select statement?
e.g.:
select db||sysdate --(this is the component where I want only 08 from the date) from gct;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way is to use the
to_charfunction this way:as documented here.
If you need the integer value, you could use the
extractfunction for dates too. Take a look here for a detailed description of theextractsyntax.For example:
would return 2008.
If you just need the value of the last two digits, you could apply the modulo function
MOD:would return 8.