Home » SQL & PL/SQL » SQL & PL/SQL » sql Functions
icon5.gif  sql Functions [message #247743] Wed, 27 June 2007 01:49 Go to next message
balaji23_d
Messages: 123
Registered: February 2007
Senior Member
hi all,


I have one doubt
i want to get the output in this format

example: select to_char(sysdate,'day')from dual;
o/p:today day(wednesday)

what my question is if i give any date,mon,year..i want to show the day of the date..

eg:suppose if i give 03/03/2007--

o/p
03--saturday
03--march

please send me the answer above questions
Re: sql Functions [message #247744 is a reply to message #247743] Wed, 27 June 2007 01:52 Go to previous messageGo to next message
caliguardo
Messages: 107
Registered: February 2007
Location: Chennai
Senior Member

select to_char(to_date('01/01/2001','dd-mm-rrrr'),'day') from dual;

try this.
Re: sql Functions [message #247745 is a reply to message #247743] Wed, 27 June 2007 01:55 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
If you know that:
1. TO_DATE(a_character_string, 'a_date_format') transforms a string into a date
2. TO_CHAR(a_date, 'DAY') will return the day of the week
3. TO_CHAR(a_date, 'MONTH') will return the name of the month

Can you solve it yourself?

First, you transform your string ('03/03/2007') into a date, but you have to tell oracle what format it is (dd/mm/yyyy or mm/dd/yyyy or another format). After that you can use the TO_CHAR.

So, a TO_CHAR(TO_DATE(...)...) construction should work.

MHE
Re: sql Functions [message #247750 is a reply to message #247745] Wed, 27 June 2007 02:05 Go to previous messageGo to next message
caliguardo
Messages: 107
Registered: February 2007
Location: Chennai
Senior Member

Maaher, Is that the answer for me or the OP?
Re: sql Functions [message #247755 is a reply to message #247750] Wed, 27 June 2007 02:18 Go to previous message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
caliguardo wrote on Wed, 27 June 2007 09:05
Maaher, Is that the answer for me or the OP?
It was an answer to balaji23_d. You seem to know those functions already Razz.

MHE
Previous Topic: Problem while calling a function in SQL
Next Topic: problem in dynamic sql
Goto Forum:
  


Current Time: Fri Dec 09 10:08:33 CST 2016

Total time taken to generate the page: 0.08131 seconds