<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SQL &#8211; Finding the Last Weekday in a Month</title>
	<atom:link href="http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/</link>
	<description>because I don't believe in life before coffee...</description>
	<lastBuildDate>Wed, 23 Nov 2011 03:01:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: theo</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-375226</link>
		<dc:creator>theo</dc:creator>
		<pubDate>Fri, 16 Oct 2009 11:17:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-375226</guid>
		<description>You could also use the oracle greatest function, thus eliminating all the unions:
&lt;code&gt;
SELECT
greatest 
(
next_day((last_day(sysdate) - 7), &#039;Monday&#039;),
next_day((last_day(sysdate) - 7), &#039;Tuesday&#039;),
next_day((last_day(sysdate) - 7), &#039;Wednesday&#039;),
next_day((last_day(sysdate) - 7), &#039;Thursday&#039;),
next_day((last_day(sysdate) - 7), &#039;Friday&#039;)
) day
from dual
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>You could also use the oracle greatest function, thus eliminating all the unions:<br />
<code><br />
SELECT<br />
greatest<br />
(<br />
next_day((last_day(sysdate) - 7), 'Monday'),<br />
next_day((last_day(sysdate) - 7), 'Tuesday'),<br />
next_day((last_day(sysdate) - 7), 'Wednesday'),<br />
next_day((last_day(sysdate) - 7), 'Thursday'),<br />
next_day((last_day(sysdate) - 7), 'Friday')<br />
) day<br />
from dual<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kintaro</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-370654</link>
		<dc:creator>kintaro</dc:creator>
		<pubDate>Thu, 23 Oct 2008 14:47:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-370654</guid>
		<description>Sorry for that here&#039;s the correct one.

with t as (
select &#039;30-sep-08&#039; toDay from dual )
select
        case
        when to_char( last_day( add_months(today, -1) ), &#039;D&#039; ) in (7, 1) then
             next_day( last_day( add_months(today, -1) ), 6 ) - 7
        else last_day( add_months( today, -1 ) )
        end last_weekday
from t</description>
		<content:encoded><![CDATA[<p>Sorry for that here&#8217;s the correct one.</p>
<p>with t as (<br />
select &#8217;30-sep-08&#8242; toDay from dual )<br />
select<br />
        case<br />
        when to_char( last_day( add_months(today, -1) ), &#8216;D&#8217; ) in (7, 1) then<br />
             next_day( last_day( add_months(today, -1) ), 6 ) &#8211; 7<br />
        else last_day( add_months( today, -1 ) )<br />
        end last_weekday<br />
from t</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kintaro</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-370653</link>
		<dc:creator>kintaro</dc:creator>
		<pubDate>Thu, 23 Oct 2008 14:38:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-370653</guid>
		<description>You could also try this one (Although this gets for the last month&#039;s last weekday):

with t as (
select &#039;01-jul-08&#039; toDay from dual )
select
        case
        when to_char( last_day( add_months(today, -1) ), &#039;D&#039; ) in (7, 1) then
             next_day( today, 6 ) - 7
        else last_day( add_months( today, -1 ) )
        end last_weekday
from t</description>
		<content:encoded><![CDATA[<p>You could also try this one (Although this gets for the last month&#8217;s last weekday):</p>
<p>with t as (<br />
select &#8217;01-jul-08&#8242; toDay from dual )<br />
select<br />
        case<br />
        when to_char( last_day( add_months(today, -1) ), &#8216;D&#8217; ) in (7, 1) then<br />
             next_day( today, 6 ) &#8211; 7<br />
        else last_day( add_months( today, -1 ) )<br />
        end last_weekday<br />
from t</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wouter</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-370080</link>
		<dc:creator>Wouter</dc:creator>
		<pubDate>Tue, 02 Sep 2008 06:47:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-370080</guid>
		<description>Unfortunately both solutions depend on the user session to use US day names. In an international environment you should either add NLS_DATE_LANGUAGE parameters, or instead of using DY, use D (which uses numeric values) to test for a given day of the week.</description>
		<content:encoded><![CDATA[<p>Unfortunately both solutions depend on the user session to use US day names. In an international environment you should either add NLS_DATE_LANGUAGE parameters, or instead of using DY, use D (which uses numeric values) to test for a given day of the week.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Skydogs</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-217677</link>
		<dc:creator>Skydogs</dc:creator>
		<pubDate>Mon, 18 Jun 2007 23:10:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-217677</guid>
		<description>Short and simple:

select 
decode(
to_char(last_day(sysdate),&#039;DY&#039;)   --FET DAY OF WEEK FOR LAST DAY OF MONTH.
,&#039;SAT&#039;,last_day(sysdate)-1 --RETURN FRIDAY
,&#039;SUN&#039;,last_day(sysdate)-2 --RETURN FRIDAY
,last_day(sysdate)  -- ELSE RETURN LAST DAY OF MONTH
) last_day_of_current_month from dual</description>
		<content:encoded><![CDATA[<p>Short and simple:</p>
<p>select<br />
decode(<br />
to_char(last_day(sysdate),&#8217;DY&#8217;)   &#8211;FET DAY OF WEEK FOR LAST DAY OF MONTH.<br />
,&#8217;SAT&#8217;,last_day(sysdate)-1 &#8211;RETURN FRIDAY<br />
,&#8217;SUN&#8217;,last_day(sysdate)-2 &#8211;RETURN FRIDAY<br />
,last_day(sysdate)  &#8212; ELSE RETURN LAST DAY OF MONTH<br />
) last_day_of_current_month from dual</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andre</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-1653</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Fri, 09 Jun 2006 17:23:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-1653</guid>
		<description>How we find in the data base all the &quot;dates&quot; that belong to the last month compared to the current date (sysdate)????????</description>
		<content:encoded><![CDATA[<p>How we find in the data base all the &#8220;dates&#8221; that belong to the last month compared to the current date (sysdate)????????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-177</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Wed, 25 Jan 2006 13:22:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-177</guid>
		<description>Veronica, unfortunately I don&#039;t have this for Access.  I&#039;m not too familiar with Access and I&#039;m sure the date functionality works differently.  Sorry.</description>
		<content:encoded><![CDATA[<p>Veronica, unfortunately I don&#8217;t have this for Access.  I&#8217;m not too familiar with Access and I&#8217;m sure the date functionality works differently.  Sorry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: VERONICA</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-174</link>
		<dc:creator>VERONICA</dc:creator>
		<pubDate>Wed, 25 Jan 2006 04:33:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-174</guid>
		<description>very handy and useful code. 
do you have the similar code for access database query for the following, get the last friday of current month?

next_day((last_day(to_date((sysdate),&#039;DD/MM/YYYY&#039;)) - 7), &#039;Friday&#039;)</description>
		<content:encoded><![CDATA[<p>very handy and useful code.<br />
do you have the similar code for access database query for the following, get the last friday of current month?</p>
<p>next_day((last_day(to_date((sysdate),&#8217;DD/MM/YYYY&#8217;)) &#8211; 7), &#8216;Friday&#8217;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-142</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Thu, 12 Jan 2006 02:14:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-142</guid>
		<description>I posted Oraboy&#039;s SQL at the bottom of this article (see UPDATE).</description>
		<content:encoded><![CDATA[<p>I posted Oraboy&#8217;s SQL at the bottom of this article (see UPDATE).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oraboy</title>
		<link>http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/comment-page-1/#comment-139</link>
		<dc:creator>Oraboy</dc:creator>
		<pubDate>Wed, 11 Jan 2006 17:55:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/01/06/sql-finding-the-last-weekday-in-a-month/#comment-139</guid>
		<description>I have posted the SQL for this here..
http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/#comment-138</description>
		<content:encoded><![CDATA[<p>I have posted the SQL for this here..<br />
<a href="http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/#comment-138" rel="nofollow">http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/#comment-138</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

