<?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>Technology Bits and Bytes &#187; Ruby</title>
	<atom:link href="http://blogs.circlesource.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.circlesource.com</link>
	<description>CircleSource Technical Talent ShowCase</description>
	<lastBuildDate>Thu, 10 Dec 2009 20:01:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title></title>
		<link>http://blogs.circlesource.com/2009/04/02/348/</link>
		<comments>http://blogs.circlesource.com/2009/04/02/348/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 11:19:47 +0000</pubDate>
		<dc:creator>nikhil.kumar</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[TIMEDIFF]]></category>
		<category><![CDATA[TIMESTAMPDIFF]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=348</guid>
		<description><![CDATA[Dealing with MySQL TIMEDIFF() for hours greater than 838
Let&#8217;s have a look at the TIMEDIFF() function in MySQL:
TIMEDIFF(expr1,expr2) - TIMEDIFF() returns expr1 &#8211; expr2 expressed as a time value. expr1 and expr2 are time or date-and-time expressions, but both must be of the same type.
It seems that when TimeDiff is performed on 2 dates that [...]]]></description>
			<content:encoded><![CDATA[<div style="font:12px;"><strong>Dealing with MySQL TIMEDIFF() for hours greater than 838</strong></p>
<p>Let&#8217;s have a look at the TIMEDIFF() function in MySQL:</p>
<p><code><strong>TIMEDIFF(<em>expr1</em>,<em>expr2</em>) -</strong></code> <code>TIMEDIFF()</code> returns <code><em>expr1</em></code> &#8211; <code><em>expr2</em></code> expressed as a time value. <code><em>expr1</em></code> and <code><em>expr2</em></code> are time or date-and-time expressions, but both must be of the same type.</p>
<p>It seems that when TimeDiff is performed on 2 dates that exceed 36 days then a warning is thrown, and the resulting value is always capped to 838.</p>
<p><strong>For example:</strong></p>
<p>select time_format(timediff(&#8216;2009-02-05 00:00:00&#8242;,&#8217;2009-01-01 00:00:00&#8242;),&#8217;%H&#8217;) as TimeDifference</p>
<p>If you execute the above query MySQL will return 838 instead of returning 840 (35 X 24 = 840).</p>
<p>The reason is precisely because TIME type in MySQL has an upper bound of 838:59:59. TIME values may range from &#8216;-838:59:59′ to &#8216;838:59:59′.</p>
<p><code>By using TIMESTAMPDIFF() function you can get around with this problem.</code></p>
<p>Let&#8217;s have a look at the <code>TIMESTAMPDIFF</code>() function in MySQL:</p>
<p><code><strong>TIMESTAMPDIFF(<em>unit</em>,<em>datetime_expr1</em>,<em>datetime_expr2</em>)</strong></code><strong> &#8211; </strong>Returns <code><em>datetime_expr2</em></code><code> - <em>datetime_expr1</em></code>, where <code><em>datetime_expr1</em></code> and <code><em>datetime_expr2</em></code> are date or datetime expressions. One expression may be a date and the other a datetime; a date value is treated as a datetime having the time part <code>'00:00:00'</code> where necessary. The unit for the result (an integer) is given by the <code><em>unit</em></code> argument. The legal values for <code><em>unit</em></code> are <code>FRAC_SECOND</code> (microseconds), <code>SECOND</code>, <code>MINUTE</code>, <code>HOUR</code>, <code>DAY</code>, <code>WEEK</code>, <code>MONTH</code>, <code>QUARTER</code>, or <code>YEAR</code>.</p>
<pre>It is bit confusing timediff and timestampdiff expects the times in opposite order.</pre>
<p>Now let&#8217;s try timestampdiff() with same dates</p>
<p>select timestampdiff(hour,&#8217;2009-01-01 00:00:00&#8242;,&#8217;2009-02-05 00:00:00&#8242;) as TimeDifference</p>
<p>If you execute the above query MySQL will return 840. Even if the difference is more than 840 it will not throw any exceptions or any warning. Hence we can use TIMESTAMPDIFF() function where the difference is more than 838 and can get the output in any of <code>FRAC_SECOND</code> (microseconds), <code>SECOND</code>, <code>MINUTE</code>, <code>HOUR</code>, <code>DAY</code>, <code>WEEK</code>, <code>MONTH</code>, <code>QUARTER</code>, or <code>YEAR</code>.</p>
<p>There you have it &#8230; I hope you enjoyed this article. Please leave comments / suggestions / questions if you have.
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/04/02/348/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DICOM File Reader in Ruby</title>
		<link>http://blogs.circlesource.com/2008/12/26/dicom-file-reader-in-ruby/</link>
		<comments>http://blogs.circlesource.com/2008/12/26/dicom-file-reader-in-ruby/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 21:03:31 +0000</pubDate>
		<dc:creator>maqbool</dc:creator>
				<category><![CDATA[DICOM]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[healthcare]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=29</guid>
		<description><![CDATA[Here is a simple DICOM file reader developed in pure ruby. The zip file also contains a driver and a sample image file
We are in the process of developing a toolkit with networking suport. We will post it hre when ready. Enjoy&#8230;.
dicomfilereader
]]></description>
			<content:encoded><![CDATA[<p>Here is a simple DICOM file reader developed in pure ruby. The zip file also contains a driver and a sample image file</p>
<p>We are in the process of developing a toolkit with networking suport. We will post it hre when ready. Enjoy&#8230;.</p>
<p><a rel="attachment wp-att-32" href="http://blogs.circlesource.com/2008/12/26/dicom-file-reader-in-ruby/dicomfilereader/">dicomfilereader</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2008/12/26/dicom-file-reader-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
