Teachnique
      CourseRoadmaps
      Login

      HomeIntroductionFeaturesVersionsVariablesInstallationAdministrationPHP SyntaxNode.js SyntaxJava SyntaxPython SyntaxConnectionWorkbench

      Create DatabaseDrop DatabaseSelect DatabaseShow DatabaseCopy DatabaseDatabase ExportDatabase ImportDatabase Info

      Create UsersDrop UsersShow UsersChange PasswordGrant PrivilegesShow PrivilegesRevoke PrivilegesLock User AccountUnlock User Account

      Create TablesShow TablesAlter TablesRename TablesClone TablesTruncate TablesTemporary TablesRepair TablesDescribe TablesAdd/Delete ColumnsShow ColumnsRename ColumnsTable LockingDrop TablesDerived Tables

      QueriesConstraintsInsert QuerySelect QueryUpdate QueryDelete QueryReplace QueryInsert IgnoreInsert on Duplicate Key UpdateInsert Into Select

      Create ViewsUpdate ViewsDrop ViewsRename Views

      IndexesCreate IndexDrop IndexShow IndexesUnique IndexClustered IndexNon-Clustered Index

      Where ClauseLimit ClauseDistinct ClauseOrder By ClauseGroup By ClauseHaving ClauseAND OperatorOR OperatorLike OperatorIN OperatorANY OperatorEXISTS OperatorNOT OperatorNOT EQUAL OperatorIS NULL OperatorIS NOT NULL OperatorBetween OperatorUNION OperatorUNION vs UNION ALLMINUS OperatorINTERSECT OperatorINTERVAL Operator

      Using JoinsInner JoinLeft JoinRight JoinCross JoinFull JoinSelf JoinDelete JoinUpdate JoinUnion vs Join

      Unique KeyPrimary KeyForeign KeyComposite KeyAlternate Key

      TriggersCreate TriggerShow TriggerDrop TriggerBefore Insert TriggerAfter Insert TriggerBefore Update TriggerAfter Update TriggerBefore Delete TriggerAfter Delete Trigger

      Data TypesVARCHARBOOLEANENUMDECIMALINTFLOATBITTINYINTBLOBSET

      Regular ExpressionsRLIKE OperatorNOT LIKE OperatorNOT REGEXP Operatorregexp_instr() Functionregexp_like() Functionregexp_replace() Functionregexp_substr() Function

      Fulltext SearchNatural Language Fulltext SearchBoolean Fulltext SearchQuery Expansion Fulltext Searchngram Fulltext Parser

      Date and Time FunctionsArithmetic OperatorsNumeric FunctionsString FunctionsAggregate Functions

      NULL ValuesTransactionsUsing SequencesHandling DuplicatesSQL InjectionSubQueryCommentsCheck ConstraintsStorage EnginesExport Table into CSV FileImport CSV File into DatabaseUUIDCommon Table ExpressionsOn Delete CascadeUpsertHorizontal PartitioningVertical PartitioningCursorStored FunctionsSignalResignalCharacter SetCollationWildcardsAliasROLLUPToday DateLiteralsStored ProcedureExplainJSONStandard DeviationFind Duplicate RecordsDelete Duplicate RecordsSelect Random RecordsShow ProcesslistChange Column TypeReset Auto-IncrementCoalesce() Function

      Useful FunctionsStatements ReferenceQuick GuideUseful ResourcesDiscussion

      Feedback

      Submit request if you have any questions.

      Course
      Date and Time Functions

      MySQL Tutorial

      This SQL tutorial is structured for beginners to guide them from the foundational concepts to advanced data manipulation and querying techniques in SQL. By the end of this tutorial, you will have developed a robust understanding of SQL, equipping you with the knowledge to efficiently manage and analyze data across various database systems. This guide sets the stage for your growth into a skilled data professional, ready to tackle complex data challenges and contribute to the field of data analysis and database management.

      Date and Time Functions

      In MySQL, we have a set of functions using which we can manipulate the date and time values. Following are the MySQL date time functions −
      
      Sr.No.
      Name & Description
      1
      ADDDATE()
      This function adds two given dates
      2
      ADDTIME()
      This function adds given time values
      3
      CONVERT_TZ()
      This function converts from one timezone to another
      4
      CURDATE()
      This function returns the current date
      5
      CURRENT_DATE(), CURRENT_DATE
      Synonyms for CURDATE()
      6
      CURRENT_TIME(), CURRENT_TIME
      Synonyms for CURTIME()
      7
      CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
      Synonyms for NOW()
      8
      CURTIME()
      This function returns the current time
      9
      DATE_ADD()
      Adds two dates
      10
      DATE_FORMAT()
      This function formats the given date as specified
      11
      DATE_SUB()
      This function subtracts two dates
      12
      DATE()
      This function extracts the date part of a date or datetime expression
      13
      DATEDIFF()
      This function subtracts two dates
      14
      DAY()
      This function retrieves the day of the month from the given date
      15
      DAYNAME()
      This function returns the name of the weekday
      16
      DAYOFMONTH()
      This function returns the day of the month (1-31)
      17
      DAYOFWEEK()
      This function returns the weekday index of the argument
      18
      DAYOFYEAR()
      This function returns the day of the year (1-366)
      19
      EXTRACT
      This function extracts part of a date
      20
      FROM_DAYS()
      This function converts a day number to a date
      21
      FROM_UNIXTIME()
      This function formats date as a UNIX timestamp
      22
      HOUR()
      This function Extracts the hour
      23
      LAST_DAY
      This function returns the last day of the month for the argument
      24
      LOCALTIME(), LOCALTIME
      Synonym for NOW()
      25
      LOCALTIMESTAMP, LOCALTIMESTAMP()
      Synonym for NOW()
      26
      MAKEDATE()
      This function creates a date from the year and day of year
      27
      MAKETIME()
      This function creates a time value from the given hours, minutes, and seconds.
      28
      MICROSECOND()
      This function returns the microseconds from argument
      29
      MINUTE()
      This function returns the minute from the argument
      30
      MONTH()
      This function returns the month from the date passed
      31
      MONTHNAME()
      This function returns the name of the month
      32
      NOW()
      This function returns the current date and time
      33
      PERIOD_ADD()
      This function adds a period to a year-month
      34
      PERIOD_DIFF()
      This function returns the number of months between periods
      35
      QUARTER()
      This function returns the quarter from a date argument
      36
      SEC_TO_TIME()
      This function converts seconds to 'HH:MM:SS' format
      37
      SECOND()
      This function returns the second (0-59)
      38
      STR_TO_DATE()
      This function converts a string to a date
      39
      SUBDATE()
      This function subtracts the specified interval to a date value
      40
      SUBTIME()
      This function subtracts the specified time interval to a date time or, time value
      41
      SYSDATE()
      This function returns the time at which the function executes
      42
      TIME_FORMAT()
      This function formats the given date in the specified format
      43
      TIME_TO_SEC()
      This function returns the argument converted to seconds
      44
      TIME()
      This function extracts the time portion of the expression passed
      45
      TIMEDIFF()
      This function subtracts two time values
      46
      TIMESTAMP()
      With a single argument, this function returns the date or datetime expression. With two arguments, the sum of the arguments
      47
      TIMESTAMPADD()
      This function adds an interval to a datetime expression
      48
      TIMESTAMPDIFF()
      This function subtracts an interval from a datetime expression
      49
      TO_DAYS()
      This function returns the date argument converted to days
      50
      UNIX_TIMESTAMP()
      This function returns a UNIX timestamp
      51
      UTC_DATE()
      This function returns the current UTC date
      52
      UTC_TIME()
      This function returns the current UTC time
      53
      UTC_TIMESTAMP()
      This function returns the current UTC date and time
      54
      WEEK()
      This function returns the week number
      55
      WEEKDAY()
      This function returns the weekday index
      56
      WEEKOFYEAR()
      This function returns the calendar week of the date (1-53)
      57
      YEAR()
      This function returns the year
      58
      YEARWEEK()
      This function returns the year and week
      59
      TO_SECONDS()
      This function converts the date or date-time values into seconds and returns the result.