<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: how to get monday=1, tuesday=2&#8230;</title>
	<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html</link>
	<description>Oracle Certified Master</description>
	<pubDate>Mon, 06 Oct 2008 22:24:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>

	<item>
		<title>by: Laurent Schneider</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-6002</link>
		<pubDate>Thu, 21 Feb 2008 17:20:58 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-6002</guid>
					<description>sure thing :)</description>
		<content:encoded><![CDATA[<p>sure thing <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Brian Tkatch</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-6001</link>
		<pubDate>Thu, 21 Feb 2008 17:18:43 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-6001</guid>
					<description>Thanx for the explanation Laurent.

I check your blog a lot, so keep on blogging! :)</description>
		<content:encoded><![CDATA[<p>Thanx for the explanation Laurent.</p>
<p>I check your blog a lot, so keep on blogging! <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Laurent Schneider</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-6000</link>
		<pubDate>Thu, 21 Feb 2008 16:05:43 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-6000</guid>
					<description>next_day is also session dependent. having a session dependent statement is way more uncomfortable. 
1) you cannot use it in materialized view
2) you cannot use it in function based index
3) you cannot have different behavior within the same statement, like displaying the default local currency, the American day of week, and the swiss short time TS (I am quite busy those days while writing about it in my book

About Dy, just to make you worry, it may changed as in changed in French from 9.2.0.8 to 10.1.0.5 from 2 chars to 4 chars abbreviation (imagine the hassle if it were hard coded in your program!) :twisted:

Well, I never use NEXT_DAY as a large number of my customers do have different locale settings. However I admit that if you never used and will never anything than american_america, then why bother, go for NEXT_DAY 8-)</description>
		<content:encoded><![CDATA[<p>next_day is also session dependent. having a session dependent statement is way more uncomfortable.<br />
1) you cannot use it in materialized view<br />
2) you cannot use it in function based index<br />
3) you cannot have different behavior within the same statement, like displaying the default local currency, the American day of week, and the swiss short time TS (I am quite busy those days while writing about it in my book</p>
<p>About Dy, just to make you worry, it may changed as in changed in French from 9.2.0.8 to 10.1.0.5 from 2 chars to 4 chars abbreviation (imagine the hassle if it were hard coded in your program!)  <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_twisted.gif' alt=':twisted:' class='wp-smiley' /> </p>
<p>Well, I never use NEXT_DAY as a large number of my customers do have different locale settings. However I admit that if you never used and will never anything than american_america, then why bother, go for NEXT_DAY <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_cool.gif' alt='8-)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Brian Tkatch</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5999</link>
		<pubDate>Thu, 21 Feb 2008 15:41:31 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5999</guid>
					<description>Ah, now i see what you did. *slaps self on head*

I could change the D to Dy, but its jsut a tradeoff of the more clear choice of using CASE/DECODE to choose the day, or to add the required amount of days. Personally, i think NEXT_DAY is a lot quite clearer.</description>
		<content:encoded><![CDATA[<p>Ah, now i see what you did. *slaps self on head*</p>
<p>I could change the D to Dy, but its jsut a tradeoff of the more clear choice of using CASE/DECODE to choose the day, or to add the required amount of days. Personally, i think NEXT_DAY is a lot quite clearer.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Laurent Schneider</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5998</link>
		<pubDate>Thu, 21 Feb 2008 14:12:53 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5998</guid>
					<description>this is all the point about using the post... Do not use 'D' ! 

Unfortunately you have no NLS_DATE_TERRITORY, therefore you cannot do something like

select to_char(sysdate,'D', 'nls_date_territory=switzerland'), to_char(sysdate,'DL','nls_date_territory=america') from dual;

it is simply impossible. But be patient, I have raised an enhancement request 4 years ago 
&lt;a href="https://metalink.oracle.com/metalink/plsql/ml2_documents.showFrameDocument?p_database_id=BUG&#038;p_id=3769415" rel="nofollow"&gt;bug 3769415&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>this is all the point about using the post&#8230; Do not use &#8216;D&#8217; ! </p>
<p>Unfortunately you have no NLS_DATE_TERRITORY, therefore you cannot do something like</p>
<p>select to_char(sysdate,&#8217;D', &#8216;nls_date_territory=switzerland&#8217;), to_char(sysdate,&#8217;DL&#8217;,'nls_date_territory=america&#8217;) from dual;</p>
<p>it is simply impossible. But be patient, I have raised an enhancement request 4 years ago<br />
<a href="https://metalink.oracle.com/metalink/plsql/ml2_documents.showFrameDocument?p_database_id=BUG&#038;p_id=3769415" rel="nofollow">bug 3769415</a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Brian Tkatch</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5997</link>
		<pubDate>Thu, 21 Feb 2008 14:03:16 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5997</guid>
					<description>For the month passing:

SELECT
	CASE
	 WHEN TO_CHAR(A, 'D') IN (7, 1) THEN NEXT_DAY(A, 2)
	 ELSE A
	END
FROM
	(SELECT TRUNC(ADD_MONTHS(SysDate, +1), 'MM') A FROM Dual);

Of course, the country's specifics require manual intervention. :)</description>
		<content:encoded><![CDATA[<p>For the month passing:</p>
<p>SELECT<br />
	CASE<br />
	 WHEN TO_CHAR(A, &#8216;D&#8217;) IN (7, 1) THEN NEXT_DAY(A, 2)<br />
	 ELSE A<br />
	END<br />
FROM<br />
	(SELECT TRUNC(ADD_MONTHS(SysDate, +1), &#8216;MM&#8217;) A FROM Dual);</p>
<p>Of course, the country&#8217;s specifics require manual intervention. <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gary</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5991</link>
		<pubDate>Wed, 20 Feb 2008 22:19:59 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5991</guid>
					<description>Interestingly, there's a difference in the way "numeric date language" and the "D" format handle territory.

&#62; alter session set nls_territory='America';

Session altered.

&#62; select to_char(sysdate,'DAY','NLS_DATE_LANGUAGE=''numeric date language'''),
2   to_char(sysdate,'DAY D') from dual;
T TO_CHAR(SYS
- -----------
4 THURSDAY  5

&#62; alter session set nls_territory='Australia';

Session altered.

&#62; select to_char(sysdate,'DAY','NLS_DATE_LANGUAGE=''numeric date language'''),
2   to_char(sysdate,'DAY D') from dual;
T TO_CHAR(SYS
- -----------
4 THURSDAY  4</description>
		<content:encoded><![CDATA[<p>Interestingly, there&#8217;s a difference in the way &#8220;numeric date language&#8221; and the &#8220;D&#8221; format handle territory.</p>
<p>&gt; alter session set nls_territory=&#8217;America&#8217;;</p>
<p>Session altered.</p>
<p>&gt; select to_char(sysdate,&#8217;DAY&#8217;,'NLS_DATE_LANGUAGE='&#8217;numeric date language&#8221;&#8217;),<br />
2   to_char(sysdate,&#8217;DAY D&#8217;) from dual;<br />
T TO_CHAR(SYS<br />
- &#8212;&#8212;&#8212;&#8211;<br />
4 THURSDAY  5</p>
<p>&gt; alter session set nls_territory=&#8217;Australia&#8217;;</p>
<p>Session altered.</p>
<p>&gt; select to_char(sysdate,&#8217;DAY&#8217;,'NLS_DATE_LANGUAGE='&#8217;numeric date language&#8221;&#8217;),<br />
2   to_char(sysdate,&#8217;DAY D&#8217;) from dual;<br />
T TO_CHAR(SYS<br />
- &#8212;&#8212;&#8212;&#8211;<br />
4 THURSDAY  4
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Laurent Schneider</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5990</link>
		<pubDate>Wed, 20 Feb 2008 21:31:26 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5990</guid>
					<description>try to upgrade to a supported release of Oracle 8)

the formatting is not necessary

select trunc(sysdate,'mm')+decode(TO_CHAR(TRUNC(sysdate,'mm'),'DY','NLS_DATE_LANGUAGE=AMERICAN'),'SAT',2,'SUN',1,0) from dual;</description>
		<content:encoded><![CDATA[<p>try to upgrade to a supported release of Oracle <img src='http://laurentschneider.com/wordpress/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> </p>
<p>the formatting is not necessary</p>
<p>select trunc(sysdate,&#8217;mm&#8217;)+decode(TO_CHAR(TRUNC(sysdate,&#8217;mm&#8217;),&#8217;DY&#8217;,'NLS_DATE_LANGUAGE=AMERICAN&#8217;),&#8217;SAT&#8217;,2,&#8217;SUN&#8217;,1,0) from dual;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Eugene</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5989</link>
		<pubDate>Wed, 20 Feb 2008 21:27:57 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5989</guid>
					<description>Laurent,
Thanks for reply, but ...
SQL&#62; select to_char(trunc(sysdate,'mm') + decode(TO_CHAR(TRUNC(sysdate,'MM'),'DY','NLS_DATE_LANGUAGE
=AMERICAN'),'SAT',2,'SUN',1,0),'DL') from dual;
select to_char(trunc(sysdate,'mm') + decode(TO_CHAR(TRUNC(sysdate,'MM'),'DY','NLS_DATE_LANGUAGE=AMER
                                                                                                    
ERROR at line 1:
ORA-01821: date format not recognized

Eugene</description>
		<content:encoded><![CDATA[<p>Laurent,<br />
Thanks for reply, but &#8230;<br />
SQL&gt; select to_char(trunc(sysdate,&#8217;mm&#8217;) + decode(TO_CHAR(TRUNC(sysdate,&#8217;MM&#8217;),&#8217;DY&#8217;,'NLS_DATE_LANGUAGE<br />
=AMERICAN&#8217;),&#8217;SAT&#8217;,2,&#8217;SUN&#8217;,1,0),&#8217;DL&#8217;) from dual;<br />
select to_char(trunc(sysdate,&#8217;mm&#8217;) + decode(TO_CHAR(TRUNC(sysdate,&#8217;MM&#8217;),&#8217;DY&#8217;,'NLS_DATE_LANGUAGE=AMER</p>
<p>ERROR at line 1:<br />
ORA-01821: date format not recognized</p>
<p>Eugene
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Laurent Schneider</title>
		<link>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5987</link>
		<pubDate>Wed, 20 Feb 2008 19:45:13 +0000</pubDate>
		<guid>http://laurentschneider.com/wordpress/2008/02/how-to-get-monday1-tuesday2.html#comment-5987</guid>
					<description>select to_char(trunc(sysdate,'mm')+decode(TO_CHAR(TRUNC(sysdate,'MM'),'DY','NLS_DATE_LANGUAGE=AMERICAN'),'SAT',2,'SUN',1,0),'DL') from dual;
TO_CHAR(TRUNC(SYSDATE,'MM')+D
-----------------------------
Friday, February 01, 2008</description>
		<content:encoded><![CDATA[<p>select to_char(trunc(sysdate,&#8217;mm&#8217;)+decode(TO_CHAR(TRUNC(sysdate,&#8217;MM&#8217;),&#8217;DY&#8217;,'NLS_DATE_LANGUAGE=AMERICAN&#8217;),&#8217;SAT&#8217;,2,&#8217;SUN&#8217;,1,0),&#8217;DL&#8217;) from dual;<br />
TO_CHAR(TRUNC(SYSDATE,&#8217;MM&#8217;)+D<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Friday, February 01, 2008
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
