{"id":74,"date":"2026-03-06T06:22:48","date_gmt":"2026-03-06T06:22:48","guid":{"rendered":"https:\/\/gigz.pk\/sql\/?post_type=lesson&#038;p=74"},"modified":"2026-03-16T18:50:04","modified_gmt":"2026-03-16T18:50:04","slug":"date-functions","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/sql\/lesson\/date-functions\/","title":{"rendered":"Date Functions"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773566513511\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Date functions are used to perform operations on date values in databases, spreadsheets, and programming languages. They help you extract, manipulate, and format dates for reporting, calculations, and automation. Understanding these functions is essential for working efficiently with data that involves dates.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Date Functions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. TODAY()<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Returns the current date.<\/li>\n\n\n\n<li>Example: <code>=TODAY()<\/code> \u2192 2026-03-06<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. NOW()<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Returns the current date and time.<\/li>\n\n\n\n<li>Example: <code>=NOW()<\/code> \u2192 2026-03-06 14:35<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. DATE(year, month, day)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creates a date from individual year, month, and day values.<\/li>\n\n\n\n<li>Example: <code>=DATE(2026, 3, 6)<\/code> \u2192 2026-03-06<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. DAY(date)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Extracts the day of the month from a date.<\/li>\n\n\n\n<li>Example: <code>=DAY(\"2026-03-06\")<\/code> \u2192 6<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. MONTH(date)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Extracts the month number from a date.<\/li>\n\n\n\n<li>Example: <code>=MONTH(\"2026-03-06\")<\/code> \u2192 3<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">6. YEAR(date)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Extracts the year from a date.<\/li>\n\n\n\n<li>Example: <code>=YEAR(\"2026-03-06\")<\/code> \u2192 2026<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">7. WEEKDAY(date)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Returns a number representing the day of the week.<\/li>\n\n\n\n<li>Example: <code>=WEEKDAY(\"2026-03-06\")<\/code> \u2192 6 (if Sunday is 1)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">8. DATEVALUE(text)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Converts a text string representing a date into a date value.<\/li>\n\n\n\n<li>Example: <code>=DATEVALUE(\"6-Mar-2026\")<\/code> \u2192 2026-03-06<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">9. DATEDIF(start_date, end_date, unit)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Calculates the difference between two dates.<\/li>\n\n\n\n<li>Units can be: \u201cD\u201d (days), \u201cM\u201d (months), \u201cY\u201d (years)<\/li>\n\n\n\n<li>Example: <code>=DATEDIF(\"2025-03-06\", \"2026-03-06\", \"Y\")<\/code> \u2192 1<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">10. EOMONTH(start_date, months)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Returns the last day of the month after adding a specified number of months.<\/li>\n\n\n\n<li>Example: <code>=EOMONTH(\"2026-03-06\", 1)<\/code> \u2192 2026-04-30<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Formatting Dates<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Dates can be displayed in various formats: <code>dd\/mm\/yyyy<\/code>, <code>mm\/dd\/yyyy<\/code>, <code>yyyy-mm-dd<\/code>.<\/li>\n\n\n\n<li>Use formatting options to display dates according to your requirements.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practical Uses<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Calculating age from a birthdate<\/li>\n\n\n\n<li>Determining due dates for tasks or invoices<\/li>\n\n\n\n<li>Finding the number of days between two events<\/li>\n\n\n\n<li>Automating monthly reports and dashboards<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Tips<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Always check the system\u2019s default date format.<\/li>\n\n\n\n<li>When working with text-based dates, use <code>DATEVALUE<\/code> to avoid errors.<\/li>\n\n\n\n<li>Combine <code>DATE<\/code> with other functions to perform advanced calculations.<\/li>\n<\/ul>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/sql\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">SQL Foundations Program (SQL-101) > Working with Functions > Date Functions<\/span><\/span><\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"menu_order":22,"template":"","class_list":["post-74","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Date Functions - SQL Learning Hub<\/title>\n<meta name=\"description\" content=\"&quot;Learn essential date functions to extract, calculate, and format dates for reports, analysis, and automated workflows efficiently.&quot;\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/sql\/lesson\/date-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Date Functions - SQL Learning Hub\" \/>\n<meta property=\"og:description\" content=\"&quot;Learn essential date functions to extract, calculate, and format dates for reports, analysis, and automated workflows efficiently.&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/sql\/lesson\/date-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Learning Hub\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-16T18:50:04+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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/date-functions\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/date-functions\\\/\",\"name\":\"Date Functions - SQL Learning Hub\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/#website\"},\"datePublished\":\"2026-03-06T06:22:48+00:00\",\"dateModified\":\"2026-03-16T18:50:04+00:00\",\"description\":\"\\\"Learn essential date functions to extract, calculate, and format dates for reports, analysis, and automated workflows efficiently.\\\"\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/date-functions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/date-functions\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/date-functions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Foundations Program (SQL-101) > Working with Functions > Date Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/\",\"name\":\"SQL Learning Hub\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/?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":"Date Functions - SQL Learning Hub","description":"\"Learn essential date functions to extract, calculate, and format dates for reports, analysis, and automated workflows efficiently.\"","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:\/\/gigz.pk\/sql\/lesson\/date-functions\/","og_locale":"en_US","og_type":"article","og_title":"Date Functions - SQL Learning Hub","og_description":"\"Learn essential date functions to extract, calculate, and format dates for reports, analysis, and automated workflows efficiently.\"","og_url":"https:\/\/gigz.pk\/sql\/lesson\/date-functions\/","og_site_name":"SQL Learning Hub","article_modified_time":"2026-03-16T18:50:04+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/sql\/lesson\/date-functions\/","url":"https:\/\/gigz.pk\/sql\/lesson\/date-functions\/","name":"Date Functions - SQL Learning Hub","isPartOf":{"@id":"https:\/\/gigz.pk\/sql\/#website"},"datePublished":"2026-03-06T06:22:48+00:00","dateModified":"2026-03-16T18:50:04+00:00","description":"\"Learn essential date functions to extract, calculate, and format dates for reports, analysis, and automated workflows efficiently.\"","breadcrumb":{"@id":"https:\/\/gigz.pk\/sql\/lesson\/date-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/sql\/lesson\/date-functions\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/sql\/lesson\/date-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/sql\/"},{"@type":"ListItem","position":2,"name":"SQL Foundations Program (SQL-101) > Working with Functions > Date Functions"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/sql\/#website","url":"https:\/\/gigz.pk\/sql\/","name":"SQL Learning Hub","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/sql\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/lesson\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/media?parent=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}