<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Get Date Time in Any Format &#8211; UDF &#8211; User Defined Functions</title>
	<atom:link href="http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tejas Shah</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-57590</link>
		<dc:creator>Tejas Shah</dc:creator>
		<pubDate>Fri, 13 Nov 2009 09:26:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-57590</guid>
		<description>Hi Ankit,

Please find attached link for the same:

h ttp://tejasnshah.wordpress.com/2008/12/22/sql-server-get-time-in-ampm-format/

Thanks,

Tejas</description>
		<content:encoded><![CDATA[<p>Hi Ankit,</p>
<p>Please find attached link for the same:</p>
<p>h ttp://tejasnshah.wordpress.com/2008/12/22/sql-server-get-time-in-ampm-format/</p>
<p>Thanks,</p>
<p>Tejas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ankit</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-57487</link>
		<dc:creator>Ankit</dc:creator>
		<pubDate>Tue, 10 Nov 2009 11:04:04 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-57487</guid>
		<description>Hi Pinal,

I want following .Net DatTime Format dd/M/yyyy h:mm:ss tt in SQL Server 2005: 


I have date in SQL Server is: 2009-11-10 16:20:42.017
and I want result as: 10/11/2009 4:20:42 PM

Regards,
Ankit</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I want following .Net DatTime Format dd/M/yyyy h:mm:ss tt in SQL Server 2005: </p>
<p>I have date in SQL Server is: 2009-11-10 16:20:42.017<br />
and I want result as: 10/11/2009 4:20:42 PM</p>
<p>Regards,<br />
Ankit</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-55417</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Mon, 31 Aug 2009 02:52:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-55417</guid>
		<description>@Mayur.

Above format is mm/dd/yy

I forgot you asked, this format : dd/mm/yyyy, to get this format, just replace, 101 by 103 in the above script. 

Script 1:
create table #Example1 ( Id int , Date Datetime )
insert into #Example1 values ( 1 , getdate())
select Id, convert (varchar, date, 103) from #Example1

Script 2:
Create table #Example2 ( Id int, Date varchar(11))
insert into #Example2 values ( 1 , convert (varchar(11),getdate(), 103))
select * from #Example2

drop table #Example1 , #Example2</description>
		<content:encoded><![CDATA[<p>@Mayur.</p>
<p>Above format is mm/dd/yy</p>
<p>I forgot you asked, this format : dd/mm/yyyy, to get this format, just replace, 101 by 103 in the above script. </p>
<p>Script 1:<br />
create table #Example1 ( Id int , Date Datetime )<br />
insert into #Example1 values ( 1 , getdate())<br />
select Id, convert (varchar, date, 103) from #Example1</p>
<p>Script 2:<br />
Create table #Example2 ( Id int, Date varchar(11))<br />
insert into #Example2 values ( 1 , convert (varchar(11),getdate(), 103))<br />
select * from #Example2</p>
<p>drop table #Example1 , #Example2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-55416</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Mon, 31 Aug 2009 02:49:49 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-55416</guid>
		<description>@Mayur, 

I have written two scripts, Execute them and check the results. 

Script 1:
create table #Example1 ( Id int , Date Datetime )
insert into #Example1 values ( 1 , getdate())
select Id, convert (varchar, date, 101)  from #Example1 

Script 2:
Create table #Example2 ( Id int, Date varchar(11))
insert into #Example2 values ( 1 , convert (varchar(11),getdate(), 101))
select * from #Example2 

drop table #Example1 , #Example2 

~IM.</description>
		<content:encoded><![CDATA[<p>@Mayur, </p>
<p>I have written two scripts, Execute them and check the results. </p>
<p>Script 1:<br />
create table #Example1 ( Id int , Date Datetime )<br />
insert into #Example1 values ( 1 , getdate())<br />
select Id, convert (varchar, date, 101)  from #Example1 </p>
<p>Script 2:<br />
Create table #Example2 ( Id int, Date varchar(11))<br />
insert into #Example2 values ( 1 , convert (varchar(11),getdate(), 101))<br />
select * from #Example2 </p>
<p>drop table #Example1 , #Example2 </p>
<p>~IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mayur dongre</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-55404</link>
		<dc:creator>mayur dongre</dc:creator>
		<pubDate>Sun, 30 Aug 2009 09:46:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-55404</guid>
		<description>i want to store date in sql server 2000 in &#039;dd/mm/yyyy&#039; formate can it is posible please tell me and give me the query how to write it.</description>
		<content:encoded><![CDATA[<p>i want to store date in sql server 2000 in &#8216;dd/mm/yyyy&#8217; formate can it is posible please tell me and give me the query how to write it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-54318</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Fri, 31 Jul 2009 12:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-54318</guid>
		<description>@MJDA

It might help to see the actual SQL statement that causes the error.

Also, the conversion can be slightly easier than you posted. For minutes, i&#039;d do it slightly differently:

DECLARE @A INT
SET @A = 1650
SELECT CAST(@A / 100 AS VARCHAR(2)) + &#039;:&#039; + CAST (CAST(60 * ((@A % 100) / 100.0) AS INT) AS VARCHAR(2))</description>
		<content:encoded><![CDATA[<p>@MJDA</p>
<p>It might help to see the actual SQL statement that causes the error.</p>
<p>Also, the conversion can be slightly easier than you posted. For minutes, i&#8217;d do it slightly differently:</p>
<p>DECLARE @A INT<br />
SET @A = 1650<br />
SELECT CAST(@A / 100 AS VARCHAR(2)) + &#8216;:&#8217; + CAST (CAST(60 * ((@A % 100) / 100.0) AS INT) AS VARCHAR(2))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MJDA</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-54302</link>
		<dc:creator>MJDA</dc:creator>
		<pubDate>Fri, 31 Jul 2009 07:21:49 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-54302</guid>
		<description>Pinal,

Happy birthday.

I have a table that has an integer field that records time taken as a whole number(don’t ask). For example 1650 = 16:30, or 35 = 00:21. Once the data is summed I want to be able to convert to a hh:mm format.

I have drafted this SQL but get error “Syntax error converting the varchar value &#039;0:0&#039; to a column of data type int.”

DECLARE @SQL_HOLDER nvarchar(3000)
SET @SQL_HOLDER = &#039;
declare @hoursall int 
declare @hours decimal(18,2)
UPDATE visits
set 	@hoursall = travel_time,
	@hours = @hoursall/100,
	travel_time = convert(varchar, convert(int, @hours)) + &#039;&#039;:&#039;&#039; + convert(varchar, convert(int, 60 * (@hours - convert(int, @hours)))) &#039;
EXEC sp_executesql @SQL_HOLDER
GO

Michael</description>
		<content:encoded><![CDATA[<p>Pinal,</p>
<p>Happy birthday.</p>
<p>I have a table that has an integer field that records time taken as a whole number(don’t ask). For example 1650 = 16:30, or 35 = 00:21. Once the data is summed I want to be able to convert to a hh:mm format.</p>
<p>I have drafted this SQL but get error “Syntax error converting the varchar value &#8216;0:0&#8242; to a column of data type int.”</p>
<p>DECLARE @SQL_HOLDER nvarchar(3000)<br />
SET @SQL_HOLDER = &#8216;<br />
declare @hoursall int<br />
declare @hours decimal(18,2)<br />
UPDATE visits<br />
set 	@hoursall = travel_time,<br />
	@hours = @hoursall/100,<br />
	travel_time = convert(varchar, convert(int, @hours)) + &#8221;:&#8221; + convert(varchar, convert(int, 60 * (@hours &#8211; convert(int, @hours)))) &#8216;<br />
EXEC sp_executesql @SQL_HOLDER<br />
GO</p>
<p>Michael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sivadutta</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-53955</link>
		<dc:creator>Sivadutta</dc:creator>
		<pubDate>Wed, 22 Jul 2009 11:55:12 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-53955</guid>
		<description>Hi Pinal,

 I have a situation in one of my project requirement.
I want date format like &quot; ,  &quot;.
Is it possible in sql 2005?
I hope I will find it out asap.Please help me out.


Regards,

Siva</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p> I have a situation in one of my project requirement.<br />
I want date format like &#8221; ,  &#8220;.<br />
Is it possible in sql 2005?<br />
I hope I will find it out asap.Please help me out.</p>
<p>Regards,</p>
<p>Siva</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ziangi</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-53783</link>
		<dc:creator>Ziangi</dc:creator>
		<pubDate>Fri, 17 Jul 2009 05:29:26 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-53783</guid>
		<description>thanks Pinal for your SQL script. :)</description>
		<content:encoded><![CDATA[<p>thanks Pinal for your SQL script. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tejasnshah</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-48515</link>
		<dc:creator>tejasnshah</dc:creator>
		<pubDate>Mon, 09 Mar 2009 10:41:36 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-48515</guid>
		<description>Hi Robin,

It looks like your data might have invalid date. 

You can use CONVERT(VARCHAR(100), GETDATE(),101) to display output in mm/dd/yyyy.

Thanks,

Tejas</description>
		<content:encoded><![CDATA[<p>Hi Robin,</p>
<p>It looks like your data might have invalid date. </p>
<p>You can use CONVERT(VARCHAR(100), GETDATE(),101) to display output in mm/dd/yyyy.</p>
<p>Thanks,</p>
<p>Tejas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-48495</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Mon, 09 Mar 2009 05:36:27 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-48495</guid>
		<description>Hi,

When i am passing @date input as dd/mm/yyyy&#039; and wanted to convert into &#039;mm/dd/yyyy&#039;. I am getting following error
&quot;The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.&quot;.

Could you please let me know what would be the best approach for it when i want to pass date as &#039;dd/mm/yyyy&#039;  and wanted the output as &#039;mm/dd/yyyy&#039;.

Thanks
Robin</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>When i am passing @date input as dd/mm/yyyy&#8217; and wanted to convert into &#8216;mm/dd/yyyy&#8217;. I am getting following error<br />
&#8220;The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.&#8221;.</p>
<p>Could you please let me know what would be the best approach for it when i want to pass date as &#8216;dd/mm/yyyy&#8217;  and wanted the output as &#8216;mm/dd/yyyy&#8217;.</p>
<p>Thanks<br />
Robin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashant</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-47571</link>
		<dc:creator>Prashant</dc:creator>
		<pubDate>Fri, 27 Feb 2009 09:36:27 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-47571</guid>
		<description>Hi Pinal ,

i want to extract time part of date .. but this function is not working ... 

SELECT [dbo].[ufsFormat] (&#039;2008-09-02 14:14:00.000&#039;, &#039;hh:mm:ss:ms AM/PM&#039;)


giving result as :

09/02/08</description>
		<content:encoded><![CDATA[<p>Hi Pinal ,</p>
<p>i want to extract time part of date .. but this function is not working &#8230; </p>
<p>SELECT [dbo].[ufsFormat] (&#8216;2008-09-02 14:14:00.000&#8242;, &#8216;hh:mm:ss:ms AM/PM&#8217;)</p>
<p>giving result as :</p>
<p>09/02/08</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice - Part 2 Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-47515</link>
		<dc:creator>SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice - Part 2 Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Thu, 26 Feb 2009 12:37:37 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-47515</guid>
		<description>[...] If you want your date in any other format refer the UDF SQL SERVER - Get Date Time in Any Format - UDF - User Defined Functions. [...]</description>
		<content:encoded><![CDATA[<p>[...] If you want your date in any other format refer the UDF SQL SERVER &#8211; Get Date Time in Any Format &#8211; UDF &#8211; User Defined Functions. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kinjal</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-45310</link>
		<dc:creator>Kinjal</dc:creator>
		<pubDate>Sat, 03 Jan 2009 11:34:23 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-45310</guid>
		<description>Hey Boss ur a Genious</description>
		<content:encoded><![CDATA[<p>Hey Boss ur a Genious</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raghunath</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-43211</link>
		<dc:creator>Raghunath</dc:creator>
		<pubDate>Wed, 24 Sep 2008 13:21:17 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-43211</guid>
		<description>Hi Pinal,

The Above function is not working when i give like the below..


SELECT [dbo].[ufsFormat] (&#039;8/7/2008&#039;, &#039;dd/mm/yy hh:mm:ss:ms AM/PM&#039;)</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>The Above function is not working when i give like the below..</p>
<p>SELECT [dbo].[ufsFormat] (&#8216;8/7/2008&#8242;, &#8216;dd/mm/yy hh:mm:ss:ms AM/PM&#8217;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tore Ajer</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-43198</link>
		<dc:creator>Tore Ajer</dc:creator>
		<pubDate>Wed, 24 Sep 2008 07:13:50 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-43198</guid>
		<description>ELSE 1 END
should be 
ELSE -1 END

in line 52</description>
		<content:encoded><![CDATA[<p>ELSE 1 END<br />
should be<br />
ELSE -1 END</p>
<p>in line 52</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: catherine</title>
		<link>http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/#comment-41772</link>
		<dc:creator>catherine</dc:creator>
		<pubDate>Tue, 19 Aug 2008 01:00:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=820#comment-41772</guid>
		<description>A very good article for asp.net newbies...Thanks Dave!!</description>
		<content:encoded><![CDATA[<p>A very good article for asp.net newbies&#8230;Thanks Dave!!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
