<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>I Learnt Today... &#187; Oracle</title>
	<atom:link href="http://www.ilearnttoday.com/category/information-technology/database/oracle/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ilearnttoday.com</link>
	<description>This is where I share what I learn day by day...</description>
	<lastBuildDate>Fri, 18 May 2012 13:36:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Oracle Trunc Function</title>
		<link>http://www.ilearnttoday.com/oracle-trunc-function</link>
		<comments>http://www.ilearnttoday.com/oracle-trunc-function#comments</comments>
		<pubDate>Mon, 24 Nov 2008 18:03:11 +0000</pubDate>
		<dc:creator>Menol</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Menol]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Cassian Menol Razeek]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[date type]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[numeric value]]></category>
		<category><![CDATA[Oracle Trunc function]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[Trunc]]></category>
		<category><![CDATA[Trunc Example]]></category>
		<category><![CDATA[Trunc function]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://ilearnttoday.wordpress.com/?p=24</guid>
		<description><![CDATA[2008-11-24 Among various helpful functions provided by Oracle, Trunc function took my attention today because I had to fix a<a href="http://www.ilearnttoday.com/oracle-trunc-function" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p><span style="color:#c0c0c0;">2008-11-24</span></p>
<p>Among various helpful functions provided by Oracle, Trunc function took my attention today because I had to fix a defect where some one has misunderstood and misused this function.</p>
<p>As the name itself suggests, the trunc function is capable of truncating a value. This function can be used either on a date type value or a numeric value.</p>
<p><strong><span style="text-decoration:underline;">Using trunc for numeric values</span></strong></p>
<p>When it comes to numbers, trunc function can return a number truncated to a certain number of decimal places.</p>
<p><span style="text-decoration:underline;">syntax:</span></p>
<p>trunc( number, [ decimal_places ] )</p>
<p><span style="text-decoration:underline;">Example usage:</span></p>
<table border="0" cellspacing="0" cellpadding="3" width="323">
<tbody>
<tr>
<td class="function_example" width="133">trunc(125.815)</td>
<td class="function_desc">would return 125</td>
</tr>
<tr>
<td class="function_example">trunc(125.815, 0)</td>
<td class="function_desc">would return 125</td>
</tr>
<tr>
<td class="function_example">trunc(125.815, 1)</td>
<td class="function_desc">would return 125.8</td>
</tr>
<tr>
<td class="function_example">trunc(125.815, 2)</td>
<td class="function_desc">would return 125.81</td>
</tr>
<tr>
<td class="function_example">trunc(125.815, 3)</td>
<td class="function_desc">would return 125.815</td>
</tr>
<tr>
<td class="function_example">trunc(-125.815, 2)</td>
<td class="function_desc">would return -125.81</td>
</tr>
<tr>
<td class="function_example">trunc(125.815, -1)</td>
<td class="function_desc">would return 120</td>
</tr>
<tr>
<td class="function_example">trunc(125.815, -2)</td>
<td class="function_desc">would return 100</td>
</tr>
<tr>
<td class="function_example">trunc(125.815, -3)</td>
<td class="function_desc">would return 0</td>
</tr>
</tbody>
</table>
<p><span style="color:#ffffff;">Menol</span></p>
<p>Note: The trunc function does not round the values like in round function. It simply truncates the number as instructed.</p>
<p><strong><span style="text-decoration:underline;">Using trunc for date values</span></strong></p>
<p>The trunc function is capable to truncate a date value to a specific unit of measure.</p>
<p><span style="text-decoration:underline;">Syntax:</span></p>
<p>trunc ( date, [ format ] )</p>
<p><span style="text-decoration:underline;">Possible values for format parameter:</span></p>
<table class="parm_values" border="1" cellspacing="0" cellpadding="3" width="386">
<tbody>
<tr class="th_left_top">
<th width="135">Unit</th>
<th>Valid format parameters</th>
</tr>
<tr>
<td>Year</td>
<td>SYYYY, YYYY, YEAR, SYEAR, YYY, YY, Y</td>
</tr>
<tr>
<td>ISO Year</td>
<td>IYYY, IY, I</td>
</tr>
<tr>
<td>Quarter</td>
<td>Q</td>
</tr>
<tr>
<td>Month</td>
<td>MONTH, MON, MM, RM</td>
</tr>
<tr>
<td>Week</td>
<td>WW</td>
</tr>
<tr>
<td>IW</td>
<td>IW</td>
</tr>
<tr>
<td>W</td>
<td>W</td>
</tr>
<tr>
<td>Day</td>
<td>DDD, DD, J</td>
</tr>
<tr>
<td>Start day of the week</td>
<td>DAY, DY, D</td>
</tr>
<tr>
<td>Hour</td>
<td>HH, HH12, HH24</td>
</tr>
<tr>
<td>Minute</td>
<td>MI</td>
</tr>
</tbody>
</table>
<p><span style="color:#ffffff;">Menol</span></p>
<p><span style="text-decoration:underline;">Example Usage:</span></p>
<table border="0" cellspacing="0" cellpadding="3" width="462">
<tbody>
<tr>
<td class="function_example" width="253">trunc(to_date(&#8217;22-AUG-03&#8242;), &#8216;YEAR&#8217;)</td>
<td class="function_desc">would return &#8217;01-JAN-03&#8242;</td>
</tr>
<tr>
<td class="function_example">trunc(to_date(&#8217;22-AUG-03&#8242;), &#8216;Q&#8217;)</td>
<td class="function_desc">would return &#8217;01-JUL-03&#8242;</td>
</tr>
<tr>
<td class="function_example">trunc(to_date(&#8217;22-AUG-03&#8242;), &#8216;MONTH&#8217;)</td>
<td class="function_desc">would return &#8217;01-AUG-03&#8242;</td>
</tr>
<tr>
<td class="function_example">trunc(to_date(&#8217;22-AUG-03&#8242;), &#8216;DDD&#8217;)</td>
<td class="function_desc">would return &#8217;22-AUG-03&#8242;</td>
</tr>
<tr>
<td class="function_example">trunc(to_date(&#8217;22-AUG-03&#8242;), &#8216;DAY&#8217;)</td>
<td class="function_desc">would return &#8217;17-AUG-03&#8242;</td>
</tr>
</tbody>
</table>
<p><span style="color:#ffffff;">Menol</span></p>
<p><span style="color:#008000;">Was this post helpful to you? How can I improve? &#8211; <span style="color:#008000;">Your comment is highly appreciated!</span></span></p>
<p><span style="color:#c0c0c0;">Cassian Menol Razeek</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ilearnttoday.com/oracle-trunc-function/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

