{"id":11635,"date":"2018-08-31T13:27:15","date_gmt":"2018-08-31T11:27:15","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/"},"modified":"2018-08-31T13:27:15","modified_gmt":"2018-08-31T11:27:15","slug":"sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/","title":{"rendered":"SQL Server Tips: How many different datetime are in my column and what the delta?"},"content":{"rendered":"<p>Few months ago, a customer asks me for finding in a column, how many rows exist with the same date &amp; time and the delta between them. The column default value \u00a0is based on the function <a title=\"MSDN to CURRENT_TIMESTAMP\" href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/current-timestamp-transact-sql?view=sql-server-2017\" target=\"_blank\">CURRENT_TIMESTAMP<\/a> and used as key as well.<br \/>\n<em>This is obviously a very bad idea but let\u2019s go ahead&#8230;<\/em><\/p>\n<p>This anti pattern may lead to a lot of duplicate keys and the customer wanted to get a picture of the situation.<\/p>\n<p>To perform this task, I used the following example which includes a temporary\u00a0table with one column with a datetime format:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">CREATE TABLE [#tmp_time_count] (dt datetime not null)<\/pre>\n<p>Let\u2019s insert a bunch a rows with CURRENT_TIMESTAMP function in the temporary table:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">INSERT INTO [#tmp_time_count] SELECT CURRENT_TIMESTAMP\nGo 1000\n<\/pre>\n<p>To get distinct datetime values , I used DISCTINCT and COUNT functions as follows:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">SELECT COUNT(DISTINCT dt) as [number_of_time_diff] from [#tmp_time_count]<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_01.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-27602 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_01.png\" alt=\"datetime_diff_01\" width=\"300\" height=\"122\" \/><\/a><br \/>\nIn my test, I find 36 different times for 1000 rows.<br \/>\nThe question now is to know how many I have on the same date &amp; time&#8230;<br \/>\nTo have this information, I try a lot of thing but finally, I write this query with a LEFT JOIN on the same table and a DATEPART on the datetime\u2019s column.<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">SELECT DISTINCT [current].dt as [Date&amp;Time], DATEPART(MILLISECOND,ISNULL([next].dt,0) \u2013[current].dt) as [time_diff] FROM [#tmp_time_count] as [current] LEFT JOIN [#tmp_time_count] as [next] on [next].dt = (SELECT MIN(dt) FROM [#tmp_time_count] WHERE dt &gt;[current].dt)<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_02.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-27601 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_02.png\" alt=\"datetime_diff_02\" width=\"300\" height=\"160\" \/><\/a><br \/>\nFinally, don\u2019t forget to drop the temporary table&#8230;.<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">DROP TABLE [#tmp_time_count];<\/pre>\n<p>Et voila! I hope this above\u00a0query will help you in a similar situation&#8230; But it&#8217;s not finished!<\/p>\n<p>Having discussed this blog post with my colleague <a title=\"David Barbarin\" href=\"https:\/\/www.dbi-services.com\/blog\/author\/david-barbarin\/\" target=\"_blank\">David Barbarin<\/a>, he suggested I continue to dig further with the performance aspect by inserting more rows (let\u2019s say 100000 rows as new exemple for this blog post).<br \/>\nlet\u2019s go!<br \/>\nTo perform this test, I enabled STATISTICS TIME &amp; IO options to get a picture of query execution statistics for each test.<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">SET STATISTICS TIME ON \nGO\nSET STATISTICS IO ON \nGO\n<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_rw01.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-28402 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_rw01.png\" alt=\"datetime_rw01\" width=\"300\" height=\"167\" \/><\/a><\/p>\n<p>As you can see on the screenshot, the CPU time is 95875ms with an number of 1322685 logical reads.<br \/>\nThis is the first step to the optimization process. I added then the following non-clustered Index:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">CREATE NONCLUSTERED INDEX [dt_idx] ON [dbo].[#tmp_time_count]\n(\n\t[dt] ASC\n)\nGO<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_rw02.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-28403 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_rw02.png\" alt=\"datetime_rw02\" width=\"300\" height=\"184\" \/><\/a><br \/>\nAfter the query execution, the new result is very better, because the CPU time dropped to 624ms with a number of logical reads equals to 205223.<br \/>\nAdding an index was helpful to get a better result but the query execution time is still tied to the number of rows in the table<br \/>\nTo get a more consistent result , David proposed one another possible solution including the <a title=\"LEAD function\" href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/lead-transact-sql?view=sql-server-2017\" target=\"_blank\">LEAD function<\/a> started since SQL Server 2012.<br \/>\nThe new query becomes:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">SELECT [current].dt, DATEPART(MILLISECOND, LEAD([current].dt, 1, 0) OVER (ORDER BY [current].dt) - [current].dt) AS [time_diff]\nFROM  [#tmp_time_count] AS [current]\n<\/pre>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_rw03.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-28404 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_rw03.png\" alt=\"datetime_rw03\" width=\"300\" height=\"179\" \/><\/a><\/p>\n<p>After running the query, CPU Time is 94ms with a number of logical reads equals to 282.<br \/>\nI was very impressed by the result with just the creation of an index and the use of the Lead function as well.<br \/>\nSo, if you face a similar situation with a high volume of data, prefer working with this last query.<br \/>\nIt was also a good reminder to have a look at the new T-SQL functions shipped with SQL Server to get faster.<br \/>\nThank you David to challenge me on this topic!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Few months ago, a customer asks me for finding in a column, how many rows exist with the same date &amp; time and the delta between them. The column default value \u00a0is based on the function CURRENT_TIMESTAMP and used as key as well. This is obviously a very bad idea but let\u2019s go ahead&#8230; This&hellip;&nbsp;<\/p>\n","protected":false},"author":15,"featured_media":11637,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","neve_meta_reading_time":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[4133,99],"tags":[49,44],"class_list":["post-11635","post","type-post","status-publish","format-standard","has-post-thumbnail","category-database","category-sql-server","tag-microsoft","tag-troubleshooting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.9 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>SQL Server Tips: How many different datetime are in my column and what the delta? - dbi services Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server Tips: How many different datetime are in my column and what the delta?\" \/>\n<meta property=\"og:description\" content=\"Few months ago, a customer asks me for finding in a column, how many rows exist with the same date &amp; time and the delta between them. The column default value \u00a0is based on the function CURRENT_TIMESTAMP and used as key as well. This is obviously a very bad idea but let\u2019s go ahead&#8230; This&hellip;&nbsp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi services Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/dbiservices\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-31T11:27:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_02.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2558\" \/>\n\t<meta property=\"og:image:height\" content=\"1368\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"St\u00e9phane Haby\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:site\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"St\u00e9phane Haby\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/\"},\"author\":{\"name\":\"St\u00e9phane Haby\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/7980252d7d7a521e285e7c66114cf82a\"},\"headline\":\"SQL Server Tips: How many different datetime are in my column and what the delta?\",\"datePublished\":\"2018-08-31T11:27:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/\"},\"wordCount\":486,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/datetime_diff_02.png\",\"keywords\":[\"Microsoft\",\"Troubleshooting\"],\"articleSection\":[\"Database\",\"SQL Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/\",\"name\":\"SQL Server Tips: How many different datetime are in my column and what the delta? - dbi services Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/datetime_diff_02.png\",\"datePublished\":\"2018-08-31T11:27:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/datetime_diff_02.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/datetime_diff_02.png\",\"width\":2558,\"height\":1368},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Tips: How many different datetime are in my column and what the delta?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi services Blog\",\"description\":\"#BeSharing\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\",\"name\":\"dbi services\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"width\":512,\"height\":512,\"caption\":\"dbi services\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/dbiservices\\\/\",\"https:\\\/\\\/x.com\\\/dbiservices\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/dbi-services\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/dbiservices\"],\"description\":\"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.\",\"email\":\"info@dbi-services.com\",\"telephone\":\"+41 32 422 96 00\",\"legalName\":\"dbi services SA\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/7980252d7d7a521e285e7c66114cf82a\",\"name\":\"St\u00e9phane Haby\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/STH_web-min-scaled.jpg\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/STH_web-min-scaled.jpg\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/STH_web-min-scaled.jpg\",\"caption\":\"St\u00e9phane Haby\"},\"description\":\"St\u00e9phane Haby has more than 20 years of experience in Microsoft solutions, specializing in the installation, migration, best practices, and performance analysis of Microsoft SQL Server, as well as Microsoft Business Intelligence solutions (SharePoint, Office) and .NET development for the banking sector. A former Microsoft Most Valuable Professional (MVP) and early adopter of Microsoft Team System in France, he has authored several technical articles. He holds Microsoft Certified Solutions Associate (MCSA) and Expert (MCSE) for SQL Server, MCTS, MCITP for SQL Server 2008, and ITIL V3 Foundation certifications. His industry experience covers chemicals and pharma, banking, and financial services.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/stephane-haby\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"SQL Server Tips: How many different datetime are in my column and what the delta? - dbi services Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server Tips: How many different datetime are in my column and what the delta?","og_description":"Few months ago, a customer asks me for finding in a column, how many rows exist with the same date &amp; time and the delta between them. The column default value \u00a0is based on the function CURRENT_TIMESTAMP and used as key as well. This is obviously a very bad idea but let\u2019s go ahead&#8230; This&hellip;&nbsp;","og_url":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/","og_site_name":"dbi services Blog","article_publisher":"https:\/\/www.facebook.com\/dbiservices\/","article_published_time":"2018-08-31T11:27:15+00:00","og_image":[{"width":2558,"height":1368,"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_02.png","type":"image\/png"}],"author":"St\u00e9phane Haby","twitter_card":"summary_large_image","twitter_creator":"@dbiservices","twitter_site":"@dbiservices","twitter_misc":{"Written by":"St\u00e9phane Haby","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/"},"author":{"name":"St\u00e9phane Haby","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/7980252d7d7a521e285e7c66114cf82a"},"headline":"SQL Server Tips: How many different datetime are in my column and what the delta?","datePublished":"2018-08-31T11:27:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/"},"wordCount":486,"commentCount":0,"publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_02.png","keywords":["Microsoft","Troubleshooting"],"articleSection":["Database","SQL Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/","url":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/","name":"SQL Server Tips: How many different datetime are in my column and what the delta? - dbi services Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_02.png","datePublished":"2018-08-31T11:27:15+00:00","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_02.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/04\/datetime_diff_02.png","width":2558,"height":1368},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/sql-server-tips-how-many-different-datetime-are-in-my-column-and-what-the-delta\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"SQL Server Tips: How many different datetime are in my column and what the delta?"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi services Blog","description":"#BeSharing","publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.dbi-services.com\/#organization","name":"dbi services","url":"https:\/\/www.dbi-services.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","width":512,"height":512,"caption":"dbi services"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/dbiservices\/","https:\/\/x.com\/dbiservices","https:\/\/www.linkedin.com\/company\/dbi-services\/","https:\/\/www.youtube.com\/user\/dbiservices"],"description":"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.","email":"info@dbi-services.com","telephone":"+41 32 422 96 00","legalName":"dbi services SA"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/7980252d7d7a521e285e7c66114cf82a","name":"St\u00e9phane Haby","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/08\/STH_web-min-scaled.jpg","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/08\/STH_web-min-scaled.jpg","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/08\/STH_web-min-scaled.jpg","caption":"St\u00e9phane Haby"},"description":"St\u00e9phane Haby has more than 20 years of experience in Microsoft solutions, specializing in the installation, migration, best practices, and performance analysis of Microsoft SQL Server, as well as Microsoft Business Intelligence solutions (SharePoint, Office) and .NET development for the banking sector. A former Microsoft Most Valuable Professional (MVP) and early adopter of Microsoft Team System in France, he has authored several technical articles. He holds Microsoft Certified Solutions Associate (MCSA) and Expert (MCSE) for SQL Server, MCTS, MCITP for SQL Server 2008, and ITIL V3 Foundation certifications. His industry experience covers chemicals and pharma, banking, and financial services.","url":"https:\/\/www.dbi-services.com\/blog\/author\/stephane-haby\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/11635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=11635"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/11635\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/11637"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=11635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=11635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=11635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}