{"id":24095,"date":"2023-03-20T07:32:00","date_gmt":"2023-03-20T06:32:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=24095"},"modified":"2023-04-05T07:04:30","modified_gmt":"2023-04-05T05:04:30","slug":"how-to-manage-dates-in-t-sql","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/","title":{"rendered":"How to manage dates in T-SQL ?"},"content":{"rendered":"\n<h4 class=\"wp-block-heading has-text-align-center\"><strong><em>T-SQL scripts to manage dates using the filter, format and calculate SQL Server functions.<\/em><\/strong><\/h4>\n\n\n\n<p>Working with dates is an essential part of any SQL developer&#8217;s skillset, as dates and times are common data types used in a variety of applications. This tutorial aims to provide a comprehensive guide on managing dates in T-SQL using a sample sales table with date columns. Various techniques for filtering, formatting, and calculating dates will be explored, while keeping the content both technical and easy to understand. Let&#8217;s dive in!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-1-set-up-the-sql-server-sample-sales-table\">1. Set up the SQL Server sample sales table<\/h2>\n\n\n\n<p>Before beginning, it is necessary to create a sample sales table with some date columns to work with. Here&#8217;s the script to create the table and insert some sample data:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE TABLE Sales (\n    OrderID INT PRIMARY KEY,\n    ProductID INT,\n    OrderDate DATE,\n    ShipDate DATE\n);\n\nINSERT INTO Sales (OrderID, ProductID, OrderDate, ShipDate)\nVALUES\n    (1, 101, '2022-01-03', '2022-01-08'),\n    (2, 102, '2022-01-04', '2022-01-09'),\n    (3, 103, '2022-01-05', '2022-01-10'),\n    (4, 104, '2022-01-06', '2022-01-11'),\n    (5, 105, '2022-01-07', '2022-01-12');\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. Manage data based on dates<\/h2>\n\n\n\n<p>It is often necessary to filter data based on date conditions. The following are 2 examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>One using a date range<\/li>\n\n\n\n<li>And one using a single date<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2.1 Find sales within a specific date range<\/h3>\n\n\n\n<p>To find sales within a specific date range, use a WHERE clause along with the BETWEEN operator to filter records based on the desired date range. This allows retrieval of sales data that falls within the specified start and end dates.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT *\nFROM Sales\nWHERE SaleDate BETWEEN '2022-01-03' AND '2022-01-05';\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2.2 Find sales on a specific day<\/h3>\n\n\n\n<p>To find sales on a specific day, use a WHERE clause with the equality operator to filter records based on the specific date.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT *\nFROM Sales\nWHERE SaleDate = '2022-01-04';\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3. Format dates in T-SQL<\/h2>\n\n\n\n<p>Formatting dates is useful when displaying them in a more human-readable form. The T-SQL built-in CONVERT function can be used for this purpose. The official standard for dates is <a href=\"https:\/\/en.wikipedia.org\/wiki\/ISO_8601\" target=\"_blank\" rel=\"noreferrer noopener\">the ISO 8601<\/a> standard. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT\n    SaleID,\n    ProductID,\n    CONVERT(VARCHAR, SaleDate, 103) AS FormattedSaleDate, -- dd\/mm\/yyyy format\n    SalePrice\nFROM Sales;\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4. Date calculations with SQL Server<\/h2>\n\n\n\n<p>Date calculations are essential for analyzing data over time. Some examples include:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.1 Calculate the difference between two dates<\/h3>\n\n\n\n<p><a href=\"https:\/\/expert-only.com\/en\/t-sql\/calculate-difference-between-two-dates\/\">To calculate the difference between two dates<\/a>, use the DATEDIFF function, which takes the date part, start date, and end date as arguments. This returns the difference between the specified dates in the desired units (e.g., days, months, years).<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DECLARE @date1 DATE = '2022-01-01';\nDECLARE @date2 DATE = '2022-01-31';\n\nSELECT DATEDIFF(DAY, @date1, @date2) AS DaysDifference;\n<\/pre>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/expert-only.com\/en\/t-sql\/calculate-difference-between-two-dates\/\n<\/div><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">4.2 Add or subtract days from a date<\/h3>\n\n\n\n<p>To add or subtract days from a date, use the DATEADD function. This function takes three arguments: the date part (e.g., day, month, year), the number to add or subtract, and the date from which to perform the operation.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT\n    OrderID,\n    OrderDate,\n    DATEADD(day, 7, OrderDate) AS MaxShippingDate\nFROM\n    Sales;\n<\/pre>\n\n\n\n<p>In the example above, seven days are added to the original <em>OrderDate<\/em>, resulting in a new column called <em>MaxShippingDate<\/em>. In real life this date could be the last date the company can ship the product to respect the delivery deadlines.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Calculate the difference between two dates<\/h2>\n\n\n\n<p>To calculate the difference between two dates, use the DATEDIFF function. This function takes three arguments: the date part, the start date, and the end date.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT\n    OrderID,\n    OrderDate,\n    ShipDate,\n    DATEDIFF(day, OrderDate, ShipDate) AS DaysBetween\nFROM\n    Sales;\n<\/pre>\n\n\n\n<p>In this example, the number of days between the OrderDate and ShipDate is calculated and displayed in a new column called DaysBetween. In a practical case it can the actual difference between the order date and the shipping date. It can be used with the maximum shipping date, for example, to calculate key performance indicators on compliance with delivery schedules.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Format dates with a specific style numer<\/h2>\n\n\n\n<p>To format dates, use the CONVERT function, which allows specifying a style for the date format. The function takes three arguments: the data type to convert to (e.g., VARCHAR), the date to convert, and the style number. In the following example, the OrderDate is converted to a formatted string using the SQL Server date style number 103 : i.e. with the <strong>dd\/mm\/yyyy<\/strong> format.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT\n    OrderID,\n    OrderDate,\n    CONVERT(VARCHAR, OrderDate, 103) AS FormattedOrderDate\nFROM\n    Sales;\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion on managing dates with T-SQL scripts<\/h2>\n\n\n\n<p>This tutorial has provided a comprehensive guide on managing dates in T-SQL using a sample sales table. The techniques demonstrated here, such as filtering, formatting, and calculating dates, are crucial for any SQL developer working with date data. By mastering these skills, one can effectively analyze and manipulate date information to meet various business requirements.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>T-SQL scripts to manage dates using the filter, format and calculate SQL Server functions. Working with dates is an essential part of any SQL developer&#8217;s skillset, as dates and times are common data types used in a variety of <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/\" title=\"How to manage dates in T-SQL ?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10829,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-24095","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-t-sql"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to manage dates in T-SQL ? SQL Server<\/title>\n<meta name=\"description\" content=\"Learn how to manage dates in T-SQL with these script examples to filter, format, and calculate dates using a sales table example.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to manage dates in T-SQL ?\" \/>\n<meta property=\"og:description\" content=\"Learn how to manage dates in T-SQL with these script examples to filter, format, and calculate dates using a sales table example.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-20T06:32:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-05T05:04:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to manage dates in T-SQL ?\",\"datePublished\":\"2023-03-20T06:32:00+00:00\",\"dateModified\":\"2023-04-05T05:04:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/\"},\"wordCount\":658,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/\",\"name\":\"How to manage dates in T-SQL ? SQL Server\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg\",\"datePublished\":\"2023-03-20T06:32:00+00:00\",\"dateModified\":\"2023-04-05T05:04:30+00:00\",\"description\":\"Learn how to manage dates in T-SQL with these script examples to filter, format, and calculate dates using a sales table example.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to manage dates in T-SQL ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to manage dates in T-SQL ? SQL Server","description":"Learn how to manage dates in T-SQL with these script examples to filter, format, and calculate dates using a sales table example.","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:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/","og_locale":"en_US","og_type":"article","og_title":"How to manage dates in T-SQL ?","og_description":"Learn how to manage dates in T-SQL with these script examples to filter, format, and calculate dates using a sales table example.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-03-20T06:32:00+00:00","article_modified_time":"2023-04-05T05:04:30+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg","type":"image\/jpeg"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to manage dates in T-SQL ?","datePublished":"2023-03-20T06:32:00+00:00","dateModified":"2023-04-05T05:04:30+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/"},"wordCount":658,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/","url":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/","name":"How to manage dates in T-SQL ? SQL Server","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg","datePublished":"2023-03-20T06:32:00+00:00","dateModified":"2023-04-05T05:04:30+00:00","description":"Learn how to manage dates in T-SQL with these script examples to filter, format, and calculate dates using a sales table example.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/pocket-watch-on-black-46ECE144EB3_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-manage-dates-in-t-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to manage dates in T-SQL ?"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/24095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=24095"}],"version-history":[{"count":0,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/24095\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10829"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=24095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=24095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=24095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}