{"id":1383,"date":"2019-02-27T10:05:06","date_gmt":"2019-02-27T03:05:06","guid":{"rendered":"http:\/\/www.sqlservertutorial.net\/?page_id=1383"},"modified":"2021-04-28T14:42:47","modified_gmt":"2021-04-28T07:42:47","slug":"sql-server-date-functions","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/","title":{"rendered":"SQL Server Date Functions"},"content":{"rendered":"\n<p>This page lists the most commonly used SQL Server Date functions that allow you to handle date and time data effectively.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Date-Functions-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1236\" height=\"523\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Date-Functions-1.png\" alt=\"SQL Server Date Functions\" class=\"wp-image-1947\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Date-Functions-1.png 1236w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Date-Functions-1-300x127.png 300w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SQL-Server-Date-Functions-1-768x325.png 768w\" sizes=\"auto, (max-width: 1236px) 100vw, 1236px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='returning-the-current-date-and-time'>Returning the current date and time <a href=\"#returning-the-current-date-and-time\" class=\"anchor\" id=\"returning-the-current-date-and-time\" title=\"Anchor for Returning the current date and time\">#<\/a><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Function<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-current_time-function\/\">CURRENT_TIMESTAMP<\/a><\/td><td>Returns the current system date and time without the time zone part.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-getutcdate-function\/\">GETUTCDATE<\/a><\/td><td>Returns a date part of a date as an integer number.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-getdate-function\/\">GETDATE<\/a><\/td><td>Returns the current system date and time of the operating system on which the SQL Server is running.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-sysdatetime-function\/\">SYSDATETIME<\/a><\/td><td>Returns the current system date and time with more fractional seconds precision than the GETDATE() function.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-sysutcdatetime-function\/\">SYSUTCDATETIME<\/a><\/td><td>Returns the current system date and time in UTC time<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-sysdatetimeoffset-function\/\">SYSDATETIMEOFFSET<\/a><\/td><td>Returns the current system date and time with the time zone.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='returning-the-date-and-time-parts'>Returning the date and time Parts <a href=\"#returning-the-date-and-time-parts\" class=\"anchor\" id=\"returning-the-date-and-time-parts\" title=\"Anchor for Returning the date and time Parts\">#<\/a><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Function<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-datename-function\/\">DATENAME<\/a><\/td><td>Returns a date part of a date as a character string<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-datepart-function\/\">DATEPART<\/a><\/td><td>Returns a date part of a date as an integer number<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-day-function\/\">DAY<\/a><\/td><td>Returns the day of a specified date as an integer<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-month-function\/\">MONTH<\/a><\/td><td>Returns the month of a specified date as an integer<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-year-function\/\">YEAR<\/a><\/td><td>Returns the year of the date as an integer.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='returning-a-difference-between-two-dates'>Returning a difference between two dates <a href=\"#returning-a-difference-between-two-dates\" class=\"anchor\" id=\"returning-a-difference-between-two-dates\" title=\"Anchor for Returning a difference between two dates\">#<\/a><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Function<\/th><th>Return value<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-datediff-function\/\">DATEDIFF<\/a><\/td><td>Returns a difference in date part between two dates.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='modifying-dates'>Modifying dates <a href=\"#modifying-dates\" class=\"anchor\" id=\"modifying-dates\" title=\"Anchor for Modifying dates\">#<\/a><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Function<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-dateadd-function\/\">DATEADD<\/a><\/td><td>Adds a value to a date part of a date and return the new date value.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-eomonth-function\/\">EOMONTH<\/a><\/td><td>Returns the last day of the month containing the specified date, with an optional offset.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-switchoffset-function\/\">SWITCHOFFSET<\/a><\/td><td>Changes the time zone offset of a <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-datetimeoffset\/\">DATETIMEOFFSET<\/a> value&nbsp;and preserves the UTC value.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-todatetimeoffset-function\/\">TODATETIMEOFFSET<\/a><\/td><td>Transforms a <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-datetime2\/\">DATETIME2<\/a> value into a <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-datetimeoffset\/\">DATETIMEOFFSET<\/a> value.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='constructing-date-and-time-from-their-parts'>Constructing date and time from their parts <a href=\"#constructing-date-and-time-from-their-parts\" class=\"anchor\" id=\"constructing-date-and-time-from-their-parts\" title=\"Anchor for Constructing date and time from their parts\">#<\/a><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Function<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-datefromparts-function\/\">DATEFROMPARTS<\/a><\/td><td>Return a <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-date\/\">DATE<\/a><\/code> value from the year, month, and day.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-datetime2fromparts-function\/\">DATETIME2FROMPARTS<\/a><\/td><td>Returns a <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-datetime2\/\">DATETIME2<\/a><\/code> value from the date and time arguments<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-datetimeoffsetfromparts-function\/\">DATETIMEOFFSETFROMPARTS<\/a><\/td><td>Returns a <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-datetimeoffset\/\">DATETIMEOFFSET<\/a><\/code> value from the date and time arguments<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-timefromparts\/\">TIMEFROMPARTS<\/a><\/td><td>Returns a <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-time\/\">TIME<\/a><\/code> value from the time parts with the precisions<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='validating-date-and-time-values'>Validating date and time values <a href=\"#validating-date-and-time-values\" class=\"anchor\" id=\"validating-date-and-time-values\" title=\"Anchor for Validating date and time values\">#<\/a><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Function<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/sql-server-isdate-function\/\">ISDATE<\/a><\/td><td>Check if a value is a valid date, time, or datetime value<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This page lists the most commonly used SQL Server Date functions that allow you to handle date and time date effectively.<\/p>\n","protected":false},"author":1,"featured_media":2735,"parent":0,"menu_order":11,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1383","page","type-page","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Server Date Functions Overview<\/title>\n<meta name=\"description\" content=\"This page lists the most commonly used SQL Server Date functions that allow you to handle date and time date effectively.\" \/>\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.sqlservertutorial.net\/sql-server-date-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server Date Functions Overview\" \/>\n<meta property=\"og:description\" content=\"This page lists the most commonly used SQL Server Date functions that allow you to handle date and time date effectively.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-28T07:42:47+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-date-functions\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-date-functions\\\/\",\"name\":\"SQL Server Date Functions Overview\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-date-functions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-date-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-date-functions.svg\",\"datePublished\":\"2019-02-27T03:05:06+00:00\",\"dateModified\":\"2021-04-28T07:42:47+00:00\",\"description\":\"This page lists the most commonly used SQL Server Date functions that allow you to handle date and time date effectively.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-date-functions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-date-functions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-date-functions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-date-functions.svg\",\"contentUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-date-functions.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-date-functions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Date Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server Date Functions Overview","description":"This page lists the most commonly used SQL Server Date functions that allow you to handle date and time date effectively.","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.sqlservertutorial.net\/sql-server-date-functions\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server Date Functions Overview","og_description":"This page lists the most commonly used SQL Server Date functions that allow you to handle date and time date effectively.","og_url":"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2021-04-28T07:42:47+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/","url":"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/","name":"SQL Server Date Functions Overview","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-date-functions.svg","datePublished":"2019-02-27T03:05:06+00:00","dateModified":"2021-04-28T07:42:47+00:00","description":"This page lists the most commonly used SQL Server Date functions that allow you to handle date and time date effectively.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/#primaryimage","url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-date-functions.svg","contentUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-date-functions.svg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-date-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQL Server Date Functions"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/1383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=1383"}],"version-history":[{"count":1,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/1383\/revisions"}],"predecessor-version":[{"id":2757,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/1383\/revisions\/2757"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media\/2735"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=1383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}