gonpla Posted December 14, 2011 Share Posted December 14, 2011 Hello,In my database I have a date field of type string, for example 20111025. I have an input field of type date and want convert to string for sql query.Could anyone help me? Thank you.Rubén. Link to comment Share on other sites More sharing options...
pioppogatto Posted December 15, 2011 Share Posted December 15, 2011 You can use to_char and to_date SQL function to convert and manage date and string TO_CHAR: Given a date ex. of 27/02/97, returns '27-FEB-97'TO_DATE: Converts a Char date to a Date data type. Examples: select TO_DATE(20111025, 'YYYYMMDD') AS DATE from dualreturns 25/10/2011 or select to_char(TO_DATE(20111025, 'YYYYMMDD'), 'YYYY') AS YEAR from dualreturns only the year 2011 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now