snippetMinor
date formatting in Oracle
Viewed 0 times
formattingoracledate
Problem
this query:
will return:
i am wondering if there are any additional formatting keywords that will allow including a list of characters like "of" , "the" ... inorder to have an output like:
or is that requires splitting the date conversion and using a concat function? thanks
for example :
select to_char(sysdate, 'Ddspth MONTH, Yyyysp') from dualwill return:
Eighteenth MARCH , Two Thousand Fourteeni am wondering if there are any additional formatting keywords that will allow including a list of characters like "of" , "the" ... inorder to have an output like:
"Today is the" Eighteenth "of" MARCH, Two Thousand Fourteenor is that requires splitting the date conversion and using a concat function? thanks
for example :
select 'Today is the ' || to_char(sysdate, 'Ddspth') || ' of' || to_char(sysdate,' MONTH, Yyyysp') from dualSolution
figured this out, here is a solution in case someone needs to do something similar...
using double quotes "" around characters will display them as they are...
will display:
using double quotes "" around characters will display them as they are...
select to_char(sysdate,'"Today is the" Ddspth "of" fmMONTH,Yyyysp') as Today from dualwill display:
"Today is the" Eighteenth "of" MARCH, Two Thousand FourteenCode Snippets
select to_char(sysdate,'"Today is the" Ddspth "of" fmMONTH,Yyyysp') as Today from dual"Today is the" Eighteenth "of" MARCH, Two Thousand FourteenContext
StackExchange Database Administrators Q#61166, answer score: 7
Revisions (0)
No revisions yet.