oz380
oz380

Reputation: 57

Change the data format

I use a script in oracle which select at a moment a date :

CURSOR SAURON IS select TOUTDOUX_ID, TYPE_OF_ACTION, USER_ID, PROFILE_NAME, START_DATE, END_DATE, PLATFORM, COMMENTS, PERM_FLAG, ACTIVE_FLAG from uam.tout_doux

But the format (25-JUL-2013) is not the one I expected (2013/07/25).
How can I select the date with the right format ?

Upvotes: 2

Views: 45

Answers (1)

Ed Gibbs
Ed Gibbs

Reputation: 26333

Use the Oracle TO_CHAR function with date-time format elements. In your case you want the format string YYYY/MM/DD:

CURSOR SAURON IS
  select TOUTDOUX_ID, TYPE_OF_ACTION, USER_ID, PROFILE_NAME,
  TO_CHAR(START_DATE, 'YYYY/MM/DD') AS SDate,
  TO_CHAR(END_DATE, 'YYYY/MM/DD') AS EDate,
  PLATFORM, COMMENTS, PERM_FLAG, ACTIVE_FLAG
from uam.tout_doux

Upvotes: 2

Related Questions