Home » SQL & PL/SQL » SQL & PL/SQL » DAY and DY functions
DAY and DY functions [message #388974] Thu, 26 February 2009 18:13 Go to next message
manju_cy
Messages: 10
Registered: February 2009
Junior Member
The below query does not work without space after THURSDAY
select *
from dual
where to_char(sysdate, 'DAY') = 'THURSDAY'

The below query works with space after THURSDAY
select *
from dual
where to_char(sysdate, 'DAY') = 'THURSDAY '

Why space is required????

DY works fine
The below query works with space after THURSDAY
select *
from dual
where to_char(sysdate, 'DY') = 'THU'
Re: DAY and DY functions [message #388980 is a reply to message #388974] Thu, 26 February 2009 19:36 Go to previous messageGo to next message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
manju_cy wrote on Fri, 27 February 2009 01:13
Why space is required????

Because Oracle implemented it so. Moreover, they also documented it in SQL Reference, available with other documentation books e.g. online on http://tahiti.oracle.com/.

For 10gR2, you may find here:
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.

In English, it is WEDNESDAY.
Re: DAY and DY functions [message #389006 is a reply to message #388974] Thu, 26 February 2009 23:22 Go to previous messageGo to next message
Michel Cadot
Messages: 64102
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
In addition, for your next posts, 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 and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Use SQL*Plus and copy and paste your session.

Regards
Michel
Re: DAY and DY functions [message #389068 is a reply to message #388980] Fri, 27 February 2009 03:13 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
If you want to remove the space padding, use the format mask 'fmDAY'
Re: DAY and DY functions [message #389196 is a reply to message #388980] Fri, 27 February 2009 10:12 Go to previous messageGo to next message
manju_cy
Messages: 10
Registered: February 2009
Junior Member
I do agree with you, for WEDNESDAY works fine without space. What I mean is it should the same way for other days also.
Re: DAY and DY functions [message #389197 is a reply to message #389068] Fri, 27 February 2009 10:15 Go to previous messageGo to next message
manju_cy
Messages: 10
Registered: February 2009
Junior Member
I can use the format mask 'fmDAY' to remove the space padding, but it works fine for WEDNESDAY without space then it should for other days also right?? I think this is a bug in Oracle.
Re: DAY and DY functions [message #389198 is a reply to message #389068] Fri, 27 February 2009 10:15 Go to previous messageGo to next message
cookiemonster
Messages: 12403
Registered: September 2008
Location: Rainy Manchester
Senior Member
JRowbottom wrote on Fri, 27 February 2009 09:13
If you want to remove the space padding, use the format mask 'fmDAY'

Re: DAY and DY functions [message #389200 is a reply to message #389196] Fri, 27 February 2009 10:18 Go to previous messageGo to next message
Michel Cadot
Messages: 64102
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
manju_cy wrote on Fri, 27 February 2009 17:12
I do agree with you, for WEDNESDAY works fine without space. What I mean is it should the same way for other days also.

You just can't read what is the definition of DAY format. There is no bug.

Regards
Michel

Re: DAY and DY functions [message #389202 is a reply to message #389200] Fri, 27 February 2009 10:22 Go to previous message
manju_cy
Messages: 10
Registered: February 2009
Junior Member
Ok thanks a lot for the information..
[DAY - Name of day, padded with blanks to display width of the widest name of day in the date language used for this element.]
Previous Topic: query
Next Topic: NEWB TO PL/SQL
Goto Forum:
  


Current Time: Fri Dec 02 14:33:54 CST 2016

Total time taken to generate the page: 0.26260 seconds