<?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: Convert an Integer Date to a Smalldatetime</title>
	<atom:link href="http://blog.boxedbits.com/archives/5/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.boxedbits.com/archives/5</link>
	<description>( ... more specifically about BI with Microsoft products )</description>
	<pubDate>Tue, 06 Jan 2009 00:10:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tom De Cort</title>
		<link>http://blog.boxedbits.com/archives/5/comment-page-1#comment-4</link>
		<dc:creator>Tom De Cort</dc:creator>
		<pubDate>Fri, 21 Dec 2007 15:28:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/5#comment-4</guid>
		<description>Code below could also do the trick:

&lt;b&gt;RETURN CAST(CAST(@yyyymmdd AS Varchar) AS DateTime)&lt;/b&gt;

Complete code of the function (with time parameter):

&lt;em&gt;
CREATE FUNCTION [dbo].[F_Convert_int_to_datetime]
(
  --parameters for the function
  @yyyymmdd int,
  @hhmmss int
)
RETURNS DateTime
AS
BEGIN
  -- Calculate and return the result of the function
  IF ISDATE(@yyyymmdd) = 1
    BEGIN 
      RETURN CAST(
                             CAST(@yyyymmdd as varchar) + ' ' + 
                             CAST(@hhmmss/10000 as varchar) + ':' +
                             CAST((@hhmmss/100)%100 as varchar) + ':' +
                             CAST((@hhmmss%100) as varchar) 
                   as datetime)
    END
  -- ELSE:
  RETURN NULL
END	
&lt;/em&gt;

Greets
-Junior Tom</description>
		<content:encoded><![CDATA[<p>Code below could also do the trick:</p>
<p><b>RETURN CAST(CAST(@yyyymmdd AS Varchar) AS DateTime)</b></p>
<p>Complete code of the function (with time parameter):</p>
<p><em><br />
CREATE FUNCTION [dbo].[F_Convert_int_to_datetime]<br />
(<br />
  &#8211;parameters for the function<br />
  @yyyymmdd int,<br />
  @hhmmss int<br />
)<br />
RETURNS DateTime<br />
AS<br />
BEGIN<br />
  &#8212; Calculate and return the result of the function<br />
  IF ISDATE(@yyyymmdd) = 1<br />
    BEGIN<br />
      RETURN CAST(<br />
                             CAST(@yyyymmdd as varchar) + &#8216; &#8216; +<br />
                             CAST(@hhmmss/10000 as varchar) + &#8216;:&#8217; +<br />
                             CAST((@hhmmss/100)%100 as varchar) + &#8216;:&#8217; +<br />
                             CAST((@hhmmss%100) as varchar)<br />
                   as datetime)<br />
    END<br />
  &#8212; ELSE:<br />
  RETURN NULL<br />
END<br />
</em></p>
<p>Greets<br />
-Junior Tom</p>
]]></content:encoded>
	</item>
</channel>
</rss>
