Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select date format ddmmyyyy from oracle database

Tags:

sql

oracle

I want to select a date field from oracle database, using select to_date(trndt, 'yyyymmdd') from cf20gldt, but the system was showing an error.

like image 743
user2786306 Avatar asked Oct 28 '13 07:10

user2786306


2 Answers

Reference

Change it as to_char

SELECT TO_CHAR(trndt, 'yyyymmdd') FROM cf20gldt;

if your trndt column is not date type then you have to change it as

SELECT TO_CHAR(TO_DATE(trndt), 'yyyymmdd') FROM cf20gldt;

For example display system date

SELECT TO_CHAR(sysdate,'yyyymmdd') FROM dual;
like image 86
Naveen Kumar Alone Avatar answered Sep 23 '22 00:09

Naveen Kumar Alone


To_date is to convert a column to date format . If your trndt is not date already then use below :

select to_char(to_date(trndt), 'yyyymmdd') from cf20gldt;

Or if your column trndate is already in date format then use below:-

select to_char(trndt, 'yyyymmdd') from cf20gldt;
like image 32
user2342436 Avatar answered Sep 22 '22 00:09

user2342436