Jump to content

Convert input type Date to String for SQL


gonpla

Recommended Posts

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 dual

returns 25/10/2011

 

or

 

select to_char(TO_DATE(20111025, 'YYYYMMDD'), 'YYYY') AS YEAR from dual

returns only the year 2011

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...