<?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: Performing Math on Oracle Dates</title>
	<atom:link href="http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/</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: Sanjay</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-379845</link>
		<dc:creator>Sanjay</dc:creator>
		<pubDate>Thu, 11 Aug 2011 10:41:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-379845</guid>
		<description>I am using following query to get difference between dates  without considering time.

select  to_date(to_char(sysdate,&#039;dd/mm/yy&#039;),&#039;dd/mm/yy&#039;)- to_date(to_char(status_date,&#039;dd/mm/yy&#039;),&#039;dd/mm/yy&#039;),   from status_table;

so that 11-Aug-2011 - 08-Aug-2011 is always 3. 

Is there any better way to do that?</description>
		<content:encoded><![CDATA[<p>I am using following query to get difference between dates  without considering time.</p>
<p>select  to_date(to_char(sysdate,&#8217;dd/mm/yy&#8217;),&#8217;dd/mm/yy&#8217;)- to_date(to_char(status_date,&#8217;dd/mm/yy&#8217;),&#8217;dd/mm/yy&#8217;),   from status_table;</p>
<p>so that 11-Aug-2011 &#8211; 08-Aug-2011 is always 3. </p>
<p>Is there any better way to do that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: c powell</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-378403</link>
		<dc:creator>c powell</dc:creator>
		<pubDate>Sun, 10 Apr 2011 12:06:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-378403</guid>
		<description>Hello,

thanks for the tips. but i want to get the number of years between sysdate and a given date. finding it difficult. the date is to be obtained from personal social number in the form yymmdd-xxxx

this query below is to get the days between then i will have to convert to years.

select upper(first_name) first_name,upper(last_name) last_name,
round((to_date(substr(pnr,1,6), &#039;yymmdd&#039;)- sysdate), 1)Age from car_owner;

I am having a problem with my results: e.g. 490321-7899, is giving me 13859.4 days but when i calculate manually it gives me about 22,665 days.

Need help to go about this.</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>thanks for the tips. but i want to get the number of years between sysdate and a given date. finding it difficult. the date is to be obtained from personal social number in the form yymmdd-xxxx</p>
<p>this query below is to get the days between then i will have to convert to years.</p>
<p>select upper(first_name) first_name,upper(last_name) last_name,<br />
round((to_date(substr(pnr,1,6), &#8216;yymmdd&#8217;)- sysdate), 1)Age from car_owner;</p>
<p>I am having a problem with my results: e.g. 490321-7899, is giving me 13859.4 days but when i calculate manually it gives me about 22,665 days.</p>
<p>Need help to go about this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramakrishna</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-375642</link>
		<dc:creator>Ramakrishna</dc:creator>
		<pubDate>Wed, 21 Apr 2010 23:05:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-375642</guid>
		<description>Anyone Please help me in deriving the following 

If i provide a date How can i derive the following using SQL scripts / SQL Queries.

1. How to get No of Weeks in a particular month.
2. How to get the Starting date&#039;s of every week
(Irrespective of Monday/thursday ...so on) for that month.
3. How to get the No of Business Days for every week.

Find the following example for reference/visualization purposes.
 
Ex: 5 Weeks (for the Month of June 2010)

No of Business 
Days in a Week		Date
---------------		-----------
Week 1 = 4		6/1/2010  (Tue)
Week 2 = 5		6/7/2010  (Mon)
Week 3 = 5		6/14/2010 (Mon)
Week 4 = 5		6/21/2010 (Mon)
Week 5 = 3		6/28/2010 (Mon)

We need the above format if we provide the date(06/01/2010 {01-Jun-2010} as a input.</description>
		<content:encoded><![CDATA[<p>Anyone Please help me in deriving the following </p>
<p>If i provide a date How can i derive the following using SQL scripts / SQL Queries.</p>
<p>1. How to get No of Weeks in a particular month.<br />
2. How to get the Starting date&#8217;s of every week<br />
(Irrespective of Monday/thursday &#8230;so on) for that month.<br />
3. How to get the No of Business Days for every week.</p>
<p>Find the following example for reference/visualization purposes.</p>
<p>Ex: 5 Weeks (for the Month of June 2010)</p>
<p>No of Business<br />
Days in a Week		Date<br />
&#8212;&#8212;&#8212;&#8212;&#8212;		&#8212;&#8212;&#8212;&#8211;<br />
Week 1 = 4		6/1/2010  (Tue)<br />
Week 2 = 5		6/7/2010  (Mon)<br />
Week 3 = 5		6/14/2010 (Mon)<br />
Week 4 = 5		6/21/2010 (Mon)<br />
Week 5 = 3		6/28/2010 (Mon)</p>
<p>We need the above format if we provide the date(06/01/2010 {01-Jun-2010} as a input.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vikram</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-369136</link>
		<dc:creator>vikram</dc:creator>
		<pubDate>Fri, 27 Jun 2008 11:02:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-369136</guid>
		<description>i hav two dates start_date and end_date the dates should be compared with sys date and the previous month of sys date..considering leap year..plz any one can send me the quey for this...</description>
		<content:encoded><![CDATA[<p>i hav two dates start_date and end_date the dates should be compared with sys date and the previous month of sys date..considering leap year..plz any one can send me the quey for this&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yasin</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-368826</link>
		<dc:creator>Yasin</dc:creator>
		<pubDate>Tue, 27 May 2008 12:54:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-368826</guid>
		<description>Hi 

I am looking oracle function where I have to compare two dates and result of comparision expressed in Month and Days.
Ex
months_between( To_Date(&#039;16-05-2008&#039;, &#039;DD-MM-YYYY&#039; ), To_Date(&#039;01-04-2008&#039;, &#039;DD-MM-YYYY&#039;)) 

expected Result 1 month 13 days

Thanks in  Advance</description>
		<content:encoded><![CDATA[<p>Hi </p>
<p>I am looking oracle function where I have to compare two dates and result of comparision expressed in Month and Days.<br />
Ex<br />
months_between( To_Date(&#8217;16-05-2008&#8242;, &#8216;DD-MM-YYYY&#8217; ), To_Date(&#8217;01-04-2008&#8242;, &#8216;DD-MM-YYYY&#8217;)) </p>
<p>expected Result 1 month 13 days</p>
<p>Thanks in  Advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-368137</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Thu, 27 Mar 2008 18:06:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-368137</guid>
		<description>I needed a &quot;where&quot; clause that selected events that occurred in previous week (Sunday midnight to Saturday 23:59:59):

&lt;code&gt;
where
	event_date between
		sysdate - (to_number(to_char(sysdate,&#039;D&#039;)) + 6) - ((to_number(to_char(sysdate,&#039;SSSSS&#039;))) /  86400)
		and
		sysdate - to_number(to_char(sysdate,&#039;D&#039;)) - (((to_number(to_char(sysdate,&#039;SSSSS&#039;))) / 86400) - .99999)
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I needed a &#8220;where&#8221; clause that selected events that occurred in previous week (Sunday midnight to Saturday 23:59:59):</p>
<p><code><br />
where<br />
	event_date between<br />
		sysdate - (to_number(to_char(sysdate,'D')) + 6) - ((to_number(to_char(sysdate,'SSSSS'))) /  86400)<br />
		and<br />
		sysdate - to_number(to_char(sysdate,'D')) - (((to_number(to_char(sysdate,'SSSSS'))) / 86400) - .99999)<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: paschima</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-366557</link>
		<dc:creator>paschima</dc:creator>
		<pubDate>Thu, 24 Jan 2008 12:35:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-366557</guid>
		<description>i want to select the date  just near by to the system date from a given data base .

Regards:
paschima</description>
		<content:encoded><![CDATA[<p>i want to select the date  just near by to the system date from a given data base .</p>
<p>Regards:<br />
paschima</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: .</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-351357</link>
		<dc:creator>.</dc:creator>
		<pubDate>Fri, 28 Dec 2007 20:30:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-351357</guid>
		<description>SELECT
( CASE
  WHEN TO_CHAR(l_date, &#039;D&#039;) = 1 THEN l_date - 2
  WHEN TO_CHAR(l_date, &#039;D&#039;) = 7 THEN l_date - 1
  WHEN TO_CHAR(l_date, &#039;D&#039;) BETWEEN 2 and 6 THEN l_date END ) Last_Weekday
FROM ( SELECT LAST_DAY(l_date) l_date FROM ( SELECT l_date FROM ( SELECT TO_DATE(&#039;&amp;YYYYMMDD&#039;, &#039;YYYYMMDD&#039;) l_date FROM dual )  ) )
/</description>
		<content:encoded><![CDATA[<p>SELECT<br />
( CASE<br />
  WHEN TO_CHAR(l_date, &#8216;D&#8217;) = 1 THEN l_date &#8211; 2<br />
  WHEN TO_CHAR(l_date, &#8216;D&#8217;) = 7 THEN l_date &#8211; 1<br />
  WHEN TO_CHAR(l_date, &#8216;D&#8217;) BETWEEN 2 and 6 THEN l_date END ) Last_Weekday<br />
FROM ( SELECT LAST_DAY(l_date) l_date FROM ( SELECT l_date FROM ( SELECT TO_DATE(&#8216;&amp;YYYYMMDD&#8217;, &#8216;YYYYMMDD&#8217;) l_date FROM dual )  ) )<br />
/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sudhakar</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-281295</link>
		<dc:creator>sudhakar</dc:creator>
		<pubDate>Mon, 10 Sep 2007 19:48:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-281295</guid>
		<description>Just use the above query in post # 6  and change 

With date_v as
(select last_day(to_date(’&amp;MM-&amp;DD-&amp;yyyyy’,&#039;MM-DD-YYYY’)) mydate from dual)
select max(date_v.mydate-(i-1)) last_weekday
from date_v,(select level i from dual connect by level between 1 and 7)
where to_char(date_v.mydate-(i-1),’Dy’) in (’Sat’,&#039;Sun’))</description>
		<content:encoded><![CDATA[<p>Just use the above query in post # 6  and change </p>
<p>With date_v as<br />
(select last_day(to_date(’&amp;MM-&amp;DD-&amp;yyyyy’,&#8217;MM-DD-YYYY’)) mydate from dual)<br />
select max(date_v.mydate-(i-1)) last_weekday<br />
from date_v,(select level i from dual connect by level between 1 and 7)<br />
where to_char(date_v.mydate-(i-1),’Dy’) in (’Sat’,&#8217;Sun’))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ajit Kumar Jha</title>
		<link>http://www.lifeaftercoffee.com/2005/11/29/performing-math-on-oracle-dates/comment-page-1/#comment-231103</link>
		<dc:creator>Ajit Kumar Jha</dc:creator>
		<pubDate>Mon, 02 Jul 2007 07:17:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/?p=100#comment-231103</guid>
		<description>I want to display the last sunday of the month. What would be query?</description>
		<content:encoded><![CDATA[<p>I want to display the last sunday of the month. What would be query?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

