Home » SQL & PL/SQL » SQL & PL/SQL » Where is wrong? (oracle 10g)
Where is wrong? [message #380693] Tue, 13 January 2009 00:57 Go to next message
rhnilu
Messages: 12
Registered: January 2009
Location: Bangladesh
Junior Member
DECLARE
V_DAY VARCHAR2(30);
BEGIN
select to_char(to_date('1-jan-09','dd-mon-yy'),'DAY') INTO V_DAY from dual;
--v_day is THURSDAY
if v_day='THURSDAY' THEN
dbms_ouTput.put_line('true');
else
dbms_ouTput.put_line('false');
end if;
end;

Why does it returns 'false'?
Re: Where is wrong? [message #380697 is a reply to message #380693] Tue, 13 January 2009 01:04 Go to previous messageGo to next message
shankhan
Messages: 28
Registered: September 2008
Location: Pakistan
Junior Member
Use this:

select trim(to_char(to_date('1-jan-09','dd-mon-yy'),'DAY')) INTO V_DAY from dual;
Re: Where is wrong? [message #380698 is a reply to message #380693] Tue, 13 January 2009 01:05 Go to previous messageGo to next message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
rhnilu wrote on Tue, 13 January 2009 07:57
Why does it returns 'false'?

Because of the format mask used. Have a look into SQL Reference, available with all Oracle documentation e.g. online on http://tahiti.oracle.com/.

Chapter 2 Basic Elements of Oracle SQL
Format Models
Datetime Format Models
Datetime Format Elements
Quote:
DAY
Name of day, padded with blanks to display width of the widest name of day in the date language used for this element.


@shankhan: Would not it be better to use "fm" format model modifier?

[Updated on: Tue, 13 January 2009 01:07]

Report message to a moderator

Re: Where is wrong? [message #380701 is a reply to message #380693] Tue, 13 January 2009 01:13 Go to previous messageGo to next message
rhnilu
Messages: 12
Registered: January 2009
Location: Bangladesh
Junior Member
It's done, THANKS BOSS
Re: Where is wrong? [message #380711 is a reply to message #380693] Tue, 13 January 2009 01:40 Go to previous message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Previous Topic: working with images
Next Topic: Understanding AUTOTRACE output
Goto Forum:
  


Current Time: Wed Dec 07 04:53:32 CST 2016

Total time taken to generate the page: 0.10568 seconds