<?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>TIMESTAMP &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/timestamp/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Mon, 09 Apr 2018 19:58:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>PostgreSQL: Get the Milliseconds from the Timestamp</title>
		<link>https://www.dbrnd.com/2018/04/postgresql-get-the-milliseconds-from-the-timestamp/</link>
					<comments>https://www.dbrnd.com/2018/04/postgresql-get-the-milliseconds-from-the-timestamp/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 10 Apr 2018 16:16:30 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[EPOCH]]></category>
		<category><![CDATA[MILLISECOND]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[TIMESTAMP]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7363</guid>

					<description><![CDATA[In this post, I am sharing a conversion statement which converts Timestamp into Milliseconds in PostgreSQL Server. There are multiple reasons where we need milliseconds from the given Timestamp like comparing the timestamp value in number format for exact matching. We can use EPOCH time format, to get the milliseconds from Timestamp. Get milliseconds without [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-get-the-milliseconds-from-the-timestamp%2F&amp;linkname=PostgreSQL%3A%20Get%20the%20Milliseconds%20from%20the%20Timestamp" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-get-the-milliseconds-from-the-timestamp%2F&amp;linkname=PostgreSQL%3A%20Get%20the%20Milliseconds%20from%20the%20Timestamp" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-get-the-milliseconds-from-the-timestamp%2F&amp;linkname=PostgreSQL%3A%20Get%20the%20Milliseconds%20from%20the%20Timestamp" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-get-the-milliseconds-from-the-timestamp%2F&amp;linkname=PostgreSQL%3A%20Get%20the%20Milliseconds%20from%20the%20Timestamp" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-get-the-milliseconds-from-the-timestamp%2F&amp;linkname=PostgreSQL%3A%20Get%20the%20Milliseconds%20from%20the%20Timestamp" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-get-the-milliseconds-from-the-timestamp%2F&amp;linkname=PostgreSQL%3A%20Get%20the%20Milliseconds%20from%20the%20Timestamp" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-get-the-milliseconds-from-the-timestamp%2F&#038;title=PostgreSQL%3A%20Get%20the%20Milliseconds%20from%20the%20Timestamp" data-a2a-url="https://www.dbrnd.com/2018/04/postgresql-get-the-milliseconds-from-the-timestamp/" data-a2a-title="PostgreSQL: Get the Milliseconds from the Timestamp"></a></p><p>In this post, I am sharing a conversion statement which converts Timestamp into Milliseconds in PostgreSQL Server.</p>
<p>There are multiple reasons where we need milliseconds from the given Timestamp like comparing the timestamp value in number format for exact matching.</p>
<p>We can use EPOCH time format, to get the milliseconds from Timestamp.</p>
<p><strong>Get milliseconds without specifying timezone:</strong></p>
<pre class="crayon-plain-tag">SELECT EXTRACT(EPOCH FROM (SELECT NOW())) * 1000;</pre> </p>
<p><strong>Get milliseconds by specifying timezone:</strong></p>
<pre class="crayon-plain-tag">SELECT EXTRACT(EPOCH FROM (SELECT NOW() AT TIME ZONE 'UTC')) * 1000;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/04/postgresql-get-the-milliseconds-from-the-timestamp/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Understand TIMESTAMP vs TIMESTAMP WITH TIME ZONE</title>
		<link>https://www.dbrnd.com/2017/12/postgresql-understand-timestamp-vs-timestamp-with-time-zone/</link>
					<comments>https://www.dbrnd.com/2017/12/postgresql-understand-timestamp-vs-timestamp-with-time-zone/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 27 Dec 2017 16:16:02 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[TIME ZONE]]></category>
		<category><![CDATA[TIMESTAMP]]></category>
		<category><![CDATA[TIMESTAMP WITH TIME ZONE]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6831</guid>

					<description><![CDATA[In this post, I am sharing a practical difference between TIMESTAMP and TIMESTAMP WITH TIME ZONE data type of PostgreSQL. Difference between datetime and timestamp in MySQL To understand the difference is a very important. Otherwise, it will affect your business or dataset. I found many people are using TIMESTAMP WITH TIME ZONE data time, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-understand-timestamp-vs-timestamp-with-time-zone%2F&amp;linkname=PostgreSQL%3A%20Understand%20TIMESTAMP%20vs%20TIMESTAMP%20WITH%20TIME%20ZONE" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-understand-timestamp-vs-timestamp-with-time-zone%2F&amp;linkname=PostgreSQL%3A%20Understand%20TIMESTAMP%20vs%20TIMESTAMP%20WITH%20TIME%20ZONE" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-understand-timestamp-vs-timestamp-with-time-zone%2F&amp;linkname=PostgreSQL%3A%20Understand%20TIMESTAMP%20vs%20TIMESTAMP%20WITH%20TIME%20ZONE" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-understand-timestamp-vs-timestamp-with-time-zone%2F&amp;linkname=PostgreSQL%3A%20Understand%20TIMESTAMP%20vs%20TIMESTAMP%20WITH%20TIME%20ZONE" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-understand-timestamp-vs-timestamp-with-time-zone%2F&amp;linkname=PostgreSQL%3A%20Understand%20TIMESTAMP%20vs%20TIMESTAMP%20WITH%20TIME%20ZONE" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-understand-timestamp-vs-timestamp-with-time-zone%2F&amp;linkname=PostgreSQL%3A%20Understand%20TIMESTAMP%20vs%20TIMESTAMP%20WITH%20TIME%20ZONE" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-understand-timestamp-vs-timestamp-with-time-zone%2F&#038;title=PostgreSQL%3A%20Understand%20TIMESTAMP%20vs%20TIMESTAMP%20WITH%20TIME%20ZONE" data-a2a-url="https://www.dbrnd.com/2017/12/postgresql-understand-timestamp-vs-timestamp-with-time-zone/" data-a2a-title="PostgreSQL: Understand TIMESTAMP vs TIMESTAMP WITH TIME ZONE"></a></p><p>In this post, I am sharing a practical difference between TIMESTAMP and TIMESTAMP WITH TIME ZONE data type of PostgreSQL. </p>
<blockquote class="wp-embedded-content" data-secret="JmkctSSPVx"><p><a href="https://www.dbrnd.com/2015/09/difference-between-datetime-and-timestamp-in-mysql/">Difference between datetime and timestamp in MySQL</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/09/difference-between-datetime-and-timestamp-in-mysql/embed/#?secret=JmkctSSPVx" data-secret="JmkctSSPVx" width="600" height="338" title="&#8220;Difference between datetime and timestamp in MySQL&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>To understand the difference is a very important. Otherwise, it will affect your business or dataset. </p>
<p>I found many people are using TIMESTAMP WITH TIME ZONE data time, without knowing that this data type will change the time value according to different TIME ZONEs. </p>
<blockquote><p>TIMESTAMP: Never change time basis on time zones<br />
TIMESTAMP WITH TIME ZONE: Change the time basis on time zones</p></blockquote>
<p><strong>Please check the below demonstration:</strong></p>
<p><strong>Create two sample tables:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE ABC (ID INT, MyTime TIMESTAMP);
CREATE TABLE XYZ (ID INT, MyTime TIMESTAMP WITH TIME ZONE);</pre> </p>
<p><strong>Insert CURRENT_TIMESTAMP:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO ABC VALUES(1, CURRENT_TIMESTAMP);
INSERT INTO XYZ VALUES(1, CURRENT_TIMESTAMP);</pre> </p>
<p><strong>Check the current timezone of your system:</strong></p>
<pre class="crayon-plain-tag">SHOW timezone;

 TimeZone
---------------
 Asia/Kolkata</pre> </p>
<p><strong>Check the table data, which entered as your system time zone:</strong></p>
<pre class="crayon-plain-tag">SELECT MyTime FROM ABC
'2017-11-28 16:45:41.782017'

SELECT MyTime FROM XYZ;
'2017-11-28 16:48:03.479841+05:30'</pre> </p>
<p><strong>Now, change the timezone in your session:</strong></p>
<pre class="crayon-plain-tag">SET timezone = 'US/Eastern';</pre> </p>
<p><strong>Now, check the table data:</strong><br />
You can see, for ABC table no change and XYZ table changed as per the new time zone. </p>
<pre class="crayon-plain-tag">SELECT MyTime FROM ABC
'2017-11-28 16:45:41.782017'

SELECT MyTime FROM XYZ;
'2017-11-28 06:18:03.479841-05'</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/12/postgresql-understand-timestamp-vs-timestamp-with-time-zone/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-12)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 23 Jun 2016 18:41:48 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[DATETIME]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[row level security]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[TIMESTAMP]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3069</guid>

					<description><![CDATA[What are the new development features of SQL Server2016? Native JSON Support Always Encrypted Query Store Live Query Statistics Row Level Security Temporal database support What does the Query Store do in SQL Server 2016? Store the history of query plans in the system. Capture the performance of each query plan over time. Identify queries [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-12)"></a></p><p><strong>What are the new development features of SQL Server2016?</strong></p>
<ul>
<li>Native JSON Support</li>
<li>Always Encrypted</li>
<li>Query Store</li>
<li>Live Query Statistics</li>
<li>Row Level Security</li>
<li>Temporal database support</li>
</ul>
<p><strong>What does the Query Store do in SQL Server 2016?</strong></p>
<ul>
<li>Store the history of query plans in the system.</li>
<li>Capture the performance of each query plan over time.</li>
<li>Identify queries that have &#8220;gotten slower recently&#8221;.</li>
<li>Allow you to force plans quickly.</li>
</ul>
<p><strong>What do you know about Live Query Statistics of SQL Server 2016?</strong></p>
<blockquote><p>It is a new feature of SQL Server2016 that allows you to view what is happening during the query execution.</p>
<p>It lets you view a list of active queries and associated statistics such as current CPU/Memory usage, execution time, query progress, and so on.</p></blockquote>
<p><strong>What is a good alternative of XML data type in SQL Server 2016?</strong></p>
<blockquote><p>The newly introduced JSON data type is one of the best option and alternative of XML data type.</p></blockquote>
<p><strong>Why JSON is becoming more important than XML?</strong></p>
<blockquote><p>One of the biggest reasons JSON is becoming more important than XML is that XML has to be parsed with an XML parser, while JSON can be parsed by a standard JavaSript function and it is very light-weight.</p>
<p>This makes it easier and faster than working with XML.</p></blockquote>
<p><strong>What is Row-Level Security in SQL Server 2016?</strong></p>
<blockquote><p>Row-Level Security: RLS enables developers and DBAs to control access to rows in a database table. Using RLS, you can store data for different customers, departments, or tenants in the same table, while restricting access to rows based on a query&#8217;s execution context.</p></blockquote>
<p><strong>What are the two types of character data SQL Server supports?</strong></p>
<ul>
<li>Regular and Unicode.</li>
<li>Char and Varchar is Regular character data type.</li>
<li>NChar and NVarchar is Unicode character data type.</li>
</ul>
<p><strong>How are literal strings expressed with the Unicode character column?</strong></p>
<blockquote><p>It must start with N&#8217;text&#8217;.</p></blockquote>
<p><strong>What is the difference between Datetime and Timestamp data types?</strong></p>
<blockquote><p>Datetime is a data type.</p>
<p>Timestamp is a data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. Timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.</p>
<p>Timestamp is a synonym of the Rowversion data type.</p></blockquote>
<p><strong>What is SWITCHOFFSET function?</strong></p>
<blockquote><p>SWITCHOFFSET function is used to convert the time from one time zone to another time zone, and it will work for date time offset fields.</p></blockquote>
<p><strong>How to SELECT n Random records from a Table in the database?</strong></p><pre class="crayon-plain-tag">SELECT TOP 3 *FROM tbl_TableName ORDER BY NEWID();</pre><p>
<strong>Which stored procedure is used to send an email in SQL Server?</strong></p>
<blockquote><p>sp_send_dbmail: The msdb database stored procedure.</p></blockquote>
<p><strong>Which stored procedure is used to update a description of the column?</strong></p>
<blockquote><p>We can update column description using sp_updateextendedproperty.</p></blockquote>
<p><strong>How we can get the Database name using SQL Command?</strong></p><pre class="crayon-plain-tag">SELECT DB_NAME();</pre><p>
<strong>I want to concatenate NULL value with string and do not require output as NULL only.</strong><br />
<strong> How do you achieve this?</strong><br />
<strong> Using,</strong></p><pre class="crayon-plain-tag">SET CONCAT_NULL_YIELDS_NULL ON / OFF;

SET CONCAT_NULL_YIELDS_NULL ON:
PRINT 'dbrnd.com' + NULL;
Result is NULL.

SET CONCAT_NULL_YIELDS_NULL OFF:
PRINT 'dbrnd.com' + NULL;
Result is dbrnd.com</pre><p>
<strong>How can you insert multiple rows together in a single insert statement?</strong></p><pre class="crayon-plain-tag">INSERT INTO tbl_Tablename 
(id,name)
VALUES
(1,'abc'),(2,'xyz'),(3,'pqr');</pre><p>
<strong>How will you delete all records of table other then recently added 10 records?</strong></p><pre class="crayon-plain-tag">DELETE FROM table_name
WHERE id not in 
(
	SELECT TOP 10 ID FROM 
	table_name ORDER BY date DESC
);</pre><p>
<strong>What is the solution of below error?</strong></p>
<p><strong>Msg 7411, Level 16, State 1, Procedure , Line 3 Server &#8216;SERVERNAME\MSSQL2012&#8217; is not configured for DATA ACCESS.</strong></p>
<p>Require to enable DATA ACCESS on SQL Server Instance.</p><pre class="crayon-plain-tag">EXEC sp_serveroption 'SERVERNAME\MSSQL2012', 'DATA ACCESS', TRUE</pre><p>
<strong>Can you execute Stored Procedure in View?</strong></p>
<blockquote><p>Yes: Using OPENQUERY, we can execute stored procedure in view.</p></blockquote>
<p><strong>What is a @@FETCH_STATUS in T-SQL?</strong></p>
<blockquote><p>To know the status of the last cursor FETCH statement issued against any cursor currently opened by the connection.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MySQL: SELECT UTC_TIMESTAMP and CONVERT local date time to UTC time zone</title>
		<link>https://www.dbrnd.com/2016/03/mysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone/</link>
					<comments>https://www.dbrnd.com/2016/03/mysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 23 Mar 2016 21:00:20 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<category><![CDATA[TIMESTAMP]]></category>
		<category><![CDATA[UTC]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2133</guid>

					<description><![CDATA[When we are working with the big distributed database system, it is very important to take care of the default database time zone. When we are selecting data from different countries, we should always work with UTC time zone because it is a World&#8217;s time standard and stand for Universal Time Coordinated. In one of [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fmysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone%2F&amp;linkname=MySQL%3A%20SELECT%20UTC_TIMESTAMP%20and%20CONVERT%20local%20date%20time%20to%20UTC%20time%20zone" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fmysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone%2F&amp;linkname=MySQL%3A%20SELECT%20UTC_TIMESTAMP%20and%20CONVERT%20local%20date%20time%20to%20UTC%20time%20zone" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fmysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone%2F&amp;linkname=MySQL%3A%20SELECT%20UTC_TIMESTAMP%20and%20CONVERT%20local%20date%20time%20to%20UTC%20time%20zone" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fmysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone%2F&amp;linkname=MySQL%3A%20SELECT%20UTC_TIMESTAMP%20and%20CONVERT%20local%20date%20time%20to%20UTC%20time%20zone" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fmysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone%2F&amp;linkname=MySQL%3A%20SELECT%20UTC_TIMESTAMP%20and%20CONVERT%20local%20date%20time%20to%20UTC%20time%20zone" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fmysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone%2F&amp;linkname=MySQL%3A%20SELECT%20UTC_TIMESTAMP%20and%20CONVERT%20local%20date%20time%20to%20UTC%20time%20zone" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fmysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone%2F&#038;title=MySQL%3A%20SELECT%20UTC_TIMESTAMP%20and%20CONVERT%20local%20date%20time%20to%20UTC%20time%20zone" data-a2a-url="https://www.dbrnd.com/2016/03/mysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone/" data-a2a-title="MySQL: SELECT UTC_TIMESTAMP and CONVERT local date time to UTC time zone"></a></p><blockquote><p>When we are working with the big distributed database system, it is very important to take care of the default database time zone.</p>
<p>When we are selecting data from different countries, we should always work with UTC time zone because it is a World&#8217;s time standard and stand for Universal Time Coordinated.</p></blockquote>
<blockquote><p>In one of our MySQL Database Server, we have stored all Date Time-related information based on local time zone.<br />
But now, the problem is some of the users are manipulating the same server from the different country.</p>
<p>This is creating a big problem for us because we cannot identify accurate Date Time values. </p></blockquote>
<p>The solution of this problem is to convert local time zone values into UTC time zone values. </p>
<p><strong>SELECT local time:</strong></p>
<pre class="crayon-plain-tag">SELECT NOW() AS Local_DateTime;</pre> </p>
<p><strong>SELECT UTC time:</strong></p>
<pre class="crayon-plain-tag">SELECT UTC_TIMESTAMP() AS UTC_DateTime;</pre> </p>
<p><strong>Convert local time to UTC time:</strong></p>
<pre class="crayon-plain-tag">SELECT CONVERT_TZ(NOW(), @@session.time_zone, '+00:00') AS UTC_DateTime;</pre> </p>
<blockquote><p><em>My suggestion is to store all Date_Time information under UTC time zone only.</em></p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/03/mysql-select-utc_timestamp-and-convert-local-date-time-to-utc-time-zone/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Update the Timestamp column with the use of TRIGGER</title>
		<link>https://www.dbrnd.com/2016/03/postgresql-update-the-timestamp-column-with-the-use-of-trigger/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 06 Mar 2016 20:12:57 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[last updated time]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[TIMESTAMP]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1904</guid>

					<description><![CDATA[Like MySQL, PostgreSQL doesn&#8217;t have different column for Datetime and Timestamp. You can visit this MySQL article here: In this post, I am sharing small demonstration on how to update a timestamp column automatically when a row is updated in the table of the PostgreSQL. In the big transactional system like the banking system, we [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-update-the-timestamp-column-with-the-use-of-trigger%2F&amp;linkname=PostgreSQL%3A%20Update%20the%20Timestamp%20column%20with%20the%20use%20of%20TRIGGER" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-update-the-timestamp-column-with-the-use-of-trigger%2F&amp;linkname=PostgreSQL%3A%20Update%20the%20Timestamp%20column%20with%20the%20use%20of%20TRIGGER" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-update-the-timestamp-column-with-the-use-of-trigger%2F&amp;linkname=PostgreSQL%3A%20Update%20the%20Timestamp%20column%20with%20the%20use%20of%20TRIGGER" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-update-the-timestamp-column-with-the-use-of-trigger%2F&amp;linkname=PostgreSQL%3A%20Update%20the%20Timestamp%20column%20with%20the%20use%20of%20TRIGGER" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-update-the-timestamp-column-with-the-use-of-trigger%2F&amp;linkname=PostgreSQL%3A%20Update%20the%20Timestamp%20column%20with%20the%20use%20of%20TRIGGER" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-update-the-timestamp-column-with-the-use-of-trigger%2F&amp;linkname=PostgreSQL%3A%20Update%20the%20Timestamp%20column%20with%20the%20use%20of%20TRIGGER" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-update-the-timestamp-column-with-the-use-of-trigger%2F&#038;title=PostgreSQL%3A%20Update%20the%20Timestamp%20column%20with%20the%20use%20of%20TRIGGER" data-a2a-url="https://www.dbrnd.com/2016/03/postgresql-update-the-timestamp-column-with-the-use-of-trigger/" data-a2a-title="PostgreSQL: Update the Timestamp column with the use of TRIGGER"></a></p><p>Like MySQL, PostgreSQL doesn&#8217;t have different column for Datetime and Timestamp.<br />
<a href="https://www.dbrnd.com/2015/09/difference-between-datetime-and-timestamp-in-mysql/" target="_blank"><strong>You can visit this MySQL article here:</strong></a></p>
<p>In this post, I am sharing small demonstration on how to update a timestamp column automatically when a row is updated in the table of the PostgreSQL.</p>
<p>In the big transactional system like the banking system, we always require last updated datetime of every transaction and row.</p>
<blockquote><p>We have also common practice to create last_modified_datetime column in table.<br />
We can also update this column using application, and we can also update this column using the user-defined function.</p>
<p>But we can also create Trigger to perform this operation, and this automatic approach is good.</p></blockquote>
<p><strong>Below is a small demonstration by creating update Trigger:</strong></p>
<p><strong>Create a sample table:</strong></p><pre class="crayon-plain-tag">CREATE TABLE tbl_EmployeeDetails
(
	EmpID SERIAL
	,EmpName CHARACTER VARYING(50)
	,EmpDOB TIMESTAMP WITHOUT TIME ZONE 
	,LastUpdatedDateTime TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW()
	,CONSTRAINT pk_tbl_EmployeeDetails_EmpID PRIMARY KEY(EmpID)
);</pre><p>
<p><strong>Insert a sample data for EmpName and EmpDOB column:</strong></p><pre class="crayon-plain-tag">INSERT INTO tbl_EmployeeDetails
(EmpName,EmpDOB)
VALUES 
('Anvesh','1988-01-26')
,('Neevan','2000-06-29')
,('Martin','1985-08-04')
,('Jeny','1990-09-12');</pre><p>
<p><strong>Create a Trigger function:</strong></p><pre class="crayon-plain-tag">CREATE OR REPLACE FUNCTION trg_fn_tbl_EmployeeDetails_LastUpdatedDateTime()
RETURNS TRIGGER AS $$
BEGIN
   NEW.LastUpdatedDateTime = NOW(); 
   RETURN NEW;
END;
$$ language 'plpgsql';</pre><p>
<p><strong>Create an UPDATE TRIGGER:</strong></p><pre class="crayon-plain-tag">CREATE TRIGGER trg_update_tbl_EmployeeDetails BEFORE UPDATE
ON tbl_EmployeeDetails FOR EACH ROW EXECUTE PROCEDURE 
trg_fn_tbl_EmployeeDetails_LastUpdatedDateTime();</pre><p>
<p><strong>Update a record and check LastUpdatedDateTime:</strong></p><pre class="crayon-plain-tag">UPDATE tbl_EmployeeDetails SET EmpDOB = '1991-09-12' WHERE EmpID=4;</pre><p>
<p><strong>The Result:</strong></p><pre class="crayon-plain-tag">SELECT *FROM tbl_EmployeeDetails;</pre><p>
<a href="https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLUpdateTimeStamp.png" rel="attachment wp-att-1908"><img fetchpriority="high" decoding="async" class="alignnone wp-image-1908 size-full" title="PostgreSQL Update TimeStamp" src="https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLUpdateTimeStamp.png" alt="PostgreSQL Update TimeStamp" width="533" height="117" srcset="https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLUpdateTimeStamp.png 533w, https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLUpdateTimeStamp-300x66.png 300w, https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLUpdateTimeStamp-150x33.png 150w" sizes="(max-width: 533px) 100vw, 533px" /></a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MySQL: Set default value for a Datetime Column</title>
		<link>https://www.dbrnd.com/2015/10/mysql-set-default-value-for-a-datetime-column/</link>
					<comments>https://www.dbrnd.com/2015/10/mysql-set-default-value-for-a-datetime-column/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 25 Oct 2015 19:05:37 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[DATETIME]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<category><![CDATA[TIMESTAMP]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=969</guid>

					<description><![CDATA[In this post, I am sharing a demonstration on how to set the default value for a Datatime column in MySQL. I know this very basic topic and nothing special about this, but I am writing here because this is one of the most asking questions by the MySQL Beginner. Following is a small demonstration [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-set-default-value-for-a-datetime-column%2F&amp;linkname=MySQL%3A%20Set%20default%20value%20for%20a%20Datetime%20Column" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-set-default-value-for-a-datetime-column%2F&amp;linkname=MySQL%3A%20Set%20default%20value%20for%20a%20Datetime%20Column" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-set-default-value-for-a-datetime-column%2F&amp;linkname=MySQL%3A%20Set%20default%20value%20for%20a%20Datetime%20Column" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-set-default-value-for-a-datetime-column%2F&amp;linkname=MySQL%3A%20Set%20default%20value%20for%20a%20Datetime%20Column" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-set-default-value-for-a-datetime-column%2F&amp;linkname=MySQL%3A%20Set%20default%20value%20for%20a%20Datetime%20Column" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-set-default-value-for-a-datetime-column%2F&amp;linkname=MySQL%3A%20Set%20default%20value%20for%20a%20Datetime%20Column" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-set-default-value-for-a-datetime-column%2F&#038;title=MySQL%3A%20Set%20default%20value%20for%20a%20Datetime%20Column" data-a2a-url="https://www.dbrnd.com/2015/10/mysql-set-default-value-for-a-datetime-column/" data-a2a-title="MySQL: Set default value for a Datetime Column"></a></p><p>In this post, I am sharing a demonstration on how to set the default value for a Datatime column in MySQL. </p>
<p>I know this very basic topic and nothing special about this, but I am writing here because this is one of the most asking questions by the MySQL Beginner. </p>
<p>Following is a small demonstration on this:</p>
<p><strong>First, Create a table with default:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE TestDefault 
(
     Name VARCHAR(50)
    ,MyDate DATETIME DEFAULT CURRENT_TIMESTAMP
);</pre> </p>
<p><strong>Second, Insert a test record:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO TestDefault(Name) VALUES ('Anvesh')</pre> </p>
<p><strong>Check the result:</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM TestDefault 

 Name  | MyDate
----------------------------
Anvesh | 2015-10-25 17:47:50</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/10/mysql-set-default-value-for-a-datetime-column/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Difference between datetime and timestamp in MySQL</title>
		<link>https://www.dbrnd.com/2015/09/difference-between-datetime-and-timestamp-in-mysql/</link>
					<comments>https://www.dbrnd.com/2015/09/difference-between-datetime-and-timestamp-in-mysql/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 04 Sep 2015 19:23:26 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[DATETIME]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<category><![CDATA[TIMESTAMP]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=505</guid>

					<description><![CDATA[In this post, I am sharing the difference between DATETIME and TIMESTAMP data type of MySQL. I am writing about this topic because this is very necessary and important for Database Developers. Even many interviewers also ask this question in the MySQL interview. For this topic, You can find many alternative answers over the internet. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fdifference-between-datetime-and-timestamp-in-mysql%2F&amp;linkname=Difference%20between%20datetime%20and%20timestamp%20in%20MySQL" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fdifference-between-datetime-and-timestamp-in-mysql%2F&amp;linkname=Difference%20between%20datetime%20and%20timestamp%20in%20MySQL" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fdifference-between-datetime-and-timestamp-in-mysql%2F&amp;linkname=Difference%20between%20datetime%20and%20timestamp%20in%20MySQL" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fdifference-between-datetime-and-timestamp-in-mysql%2F&amp;linkname=Difference%20between%20datetime%20and%20timestamp%20in%20MySQL" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fdifference-between-datetime-and-timestamp-in-mysql%2F&amp;linkname=Difference%20between%20datetime%20and%20timestamp%20in%20MySQL" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fdifference-between-datetime-and-timestamp-in-mysql%2F&amp;linkname=Difference%20between%20datetime%20and%20timestamp%20in%20MySQL" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fdifference-between-datetime-and-timestamp-in-mysql%2F&#038;title=Difference%20between%20datetime%20and%20timestamp%20in%20MySQL" data-a2a-url="https://www.dbrnd.com/2015/09/difference-between-datetime-and-timestamp-in-mysql/" data-a2a-title="Difference between datetime and timestamp in MySQL"></a></p><p>In this post, I am sharing the difference between DATETIME and TIMESTAMP data type of MySQL.</p>
<p>I am writing about this topic because this is very necessary and important for Database Developers.<br />
Even many interviewers also ask this question in the MySQL interview. </p>
<p>For this topic, You can find many alternative answers over the internet. But still, I love to write in my way.</p>
<p><strong>DATETIME vs TIMESTAMP:</strong></p>
<blockquote><p>TIMESTAMP used to track changes of records, and update every time when the record is changed.<br />
DATETIME used to store specific and static value which is not affected by any changes in records.</p></blockquote>
<blockquote><p>TIMESTAMP also affected by different TIME ZONE related setting.<br />
DATETIME is constant.</p></blockquote>
<blockquote><p>TIMESTAMP internally converted a current time zone to UTC for storage, and during retrieval convert the back to the current time zone.<br />
DATETIME can not do this.</p></blockquote>
<blockquote><p>TIMESTAMP is 4 bytes and DATETIME is 8 bytes.</p></blockquote>
<blockquote><p>TIMESTAMP supported range:<br />
&#8216;1970-01-01 00:00:01′ UTC to &#8216;2038-01-19 03:14:07′ UTC<br />
DATETIME supported range:<br />
&#8216;1000-01-01 00:00:00′ to &#8216;9999-12-31 23:59:59′</p></blockquote>
<p><strong>Let me demonstrate a small practical example:</strong></p>
<p><strong>Create test table and insert NOW() in the both column:</strong></p><pre class="crayon-plain-tag">CREATE TABLE tbl_TestDateType
(
    ID INTEGER
    ,Date1 DATETIME
    ,Date2 TIMESTAMP 
);

INSERT INTO tbl_TestDateType 
VALUES (1,NOW(),NOW());</pre><p>
<p><strong>Update a record after a few seconds:</strong></p><pre class="crayon-plain-tag">UPDATE tbl_TestDateType SET ID=2;</pre><p>
Check the value for both date, You will find old value in DATETIME column and updated TIMESTAMP column.</p>
<pre class="crayon-plain-tag">SELECT * FROM tbl_TestDateType;</pre>
<p><a href="https://www.dbrnd.com/wp-content/uploads/2015/08/MySQLDateTime.png"><img decoding="async" class="alignnone wp-image-513 size-full" title="MySQL DateTime vs Timestamp" src="https://www.dbrnd.com/wp-content/uploads/2015/08/MySQLDateTime.png" alt="MySQL DateTime Timestamp" width="268" height="60" srcset="https://www.dbrnd.com/wp-content/uploads/2015/08/MySQLDateTime.png 268w, https://www.dbrnd.com/wp-content/uploads/2015/08/MySQLDateTime-150x34.png 150w" sizes="(max-width: 268px) 100vw, 268px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/09/difference-between-datetime-and-timestamp-in-mysql/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
