<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Eddie Awad’s Blog - Latest Comments in Cool SQL function: EXTRACT</title><link>http://awads.disqus.com/</link><description>News, views, tips and tricks on Oracle and other fun stuff</description><atom:link href="https://awads.disqus.com/cool_sql_function_extract/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 20 Mar 2008 14:30:15 -0000</lastBuildDate><item><title>Re: Cool SQL function: EXTRACT</title><link>http://awads.net/wp/2005/12/28/cool-sql-function-extract/#comment-3658144</link><description>&lt;p&gt;@Gary: Good idea. Here is an example&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;select&lt;br&gt;    extract(hour from cast(sysdate as timestamp)) hh,&lt;br&gt;    extract(minute from cast(sysdate as timestamp)) mi,&lt;br&gt;    extract(second from cast(sysdate as timestamp))ss&lt;br&gt;from dual&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;Thanks.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Thu, 20 Mar 2008 14:30:15 -0000</pubDate></item><item><title>Re: Cool SQL function: EXTRACT</title><link>http://awads.net/wp/2005/12/28/cool-sql-function-extract/#comment-3658143</link><description>&lt;p&gt;You can cast a date to a timestamp and then extract the hour.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gary Menchen</dc:creator><pubDate>Wed, 19 Mar 2008 16:41:15 -0000</pubDate></item><item><title>Re: Cool SQL function: EXTRACT</title><link>http://awads.net/wp/2005/12/28/cool-sql-function-extract/#comment-3658142</link><description>&lt;p&gt;Well, this isn't so useful if you want the name of the day instead of a number. Say, "MON" instead of 2. Back to TO_CHAR!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Glenn</dc:creator><pubDate>Tue, 18 Sep 2007 22:55:35 -0000</pubDate></item><item><title>Re: Cool SQL function: EXTRACT</title><link>http://awads.net/wp/2005/12/28/cool-sql-function-extract/#comment-3658137</link><description>&lt;p&gt;Yes, I just used this the other day.  I wrapped it in a DECODE to get a text representation of the month.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Rob Vollman</dc:creator><pubDate>Thu, 29 Dec 2005 14:35:06 -0000</pubDate></item><item><title>Re: Cool SQL function: EXTRACT</title><link>http://awads.net/wp/2005/12/28/cool-sql-function-extract/#comment-3658141</link><description>&lt;p&gt;&lt;i&gt;you cannot extract Hour, minute or second from a date&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Yes, the documentation says: &lt;i&gt;The field you are extracting must be a field of the datetime_value_expr or interval_value_expr. For example, you can extract only YEAR, MONTH, and DAY from a DATE value.&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;I'm not sure exactly why you cannot get to the hour/minute/second from a DATE using EXTRACT, since a DATE datatype contains a time portion as well (but not fractional seconds).&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;It'll be interesting to know what the reason behind this limitation is.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Wed, 28 Dec 2005 12:57:23 -0000</pubDate></item><item><title>Re: Cool SQL function: EXTRACT</title><link>http://awads.net/wp/2005/12/28/cool-sql-function-extract/#comment-3658140</link><description>&lt;p&gt;You can also get this information with the To_Char() function.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;SELECT to_char(SYSTIMESTAMP,'FF') FROM dual&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">FranÃ§ois</dc:creator><pubDate>Wed, 28 Dec 2005 10:12:40 -0000</pubDate></item><item><title>Re: Cool SQL function: EXTRACT</title><link>http://awads.net/wp/2005/12/28/cool-sql-function-extract/#comment-3658139</link><description>&lt;p&gt;interesting is extracting nanoseconds from timestamp :&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;SQL&amp;gt; create table t as select timestamp '2000-01-01 00:00:42.123456789' t from dual;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Table created.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;SQL&amp;gt; select mod(extract(second from t),1)*1000000000 ns from t;&lt;br&gt;        NS&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;123456789&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Laurent Schneider</dc:creator><pubDate>Wed, 28 Dec 2005 09:36:36 -0000</pubDate></item><item><title>Re: Cool SQL function: EXTRACT</title><link>http://awads.net/wp/2005/12/28/cool-sql-function-extract/#comment-3658138</link><description>&lt;p&gt;For an unknown reason you cannot extract Hour, minute or second from a date. It works only on Timestamp.&lt;br&gt;Francois&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">FranÃ§ois</dc:creator><pubDate>Wed, 28 Dec 2005 08:36:39 -0000</pubDate></item></channel></rss>