Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

MySQL SYSDATE Function

by suresh

MySQL SYSDATE function is one of the MySQL Date Functions, which returns the current system Date and Time in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS.uuuu format.

In this article, we show how to use this MySQL SYSDATE function to find the current date and time with an example. The basic syntax of the SYSDATE() Function in MySQL is as shown below:

SYSDATE();

MySQL SYSDATE function Example

The below-shown query shows you the basic use of this SYSDATE function to return or find the current date and time.

SELECT SYSDATE();

SELECT SYSDATE() AS 'Todays Date and Time';

SELECT SYSDATE() AS 'Date and Time';

As you can see from the screenshot below, it returns the current system date and Time in YYYY-MM-DD HH:MM:SS format. Within the last two MySQL statements, we used the Alias Names.

MySQL SYSDATE Function 1

The following query shows you what happens when we add or subtract value to this SYSDATE function output.

SELECT SYSDATE() + 0;

SELECT SYSDATE(), SYSDATE() + 5;

SELECT SYSDATE(), SYSDATE() - 5;
MySQL SYSDATE Function 2

As you can see from the above screenshot, it added and subtracted those values to the current system date and time. Next, it was displayed the DateTime in YYYYMMDDHHMMSS string format

MySQL SYSDATE function Example 2

In most cases, the NOW and SYSTEM functions return the same output. They differ in the execution time. I mean, SYSDATE Date Function returns the value when executes, NOW returns the constant time. Let us see one example.

SELECT SYSDATE(), NOW();

SELECT NOW(), SLEEP(2), NOW();

SELECT SYSDATE(), SLEEP(2), SYSDATE();
MySQL SYSDATE Function 3

MySQL SYSDATE Example 3

In this instance, we show how to use this SYSDATE function on table data. Here, we are using a datediff function to find the difference between the current system DateTime and the Hire Date column value.

For this MySQL SYSDATE demonstration, we are using Workbench to write a query against the customer database.

SELECT EmpID,
FirstName,
LastName,
Occupation,
YearlyIncome,
Sales,
HireDate,
DATEDIFF(SYSDATE(), HireDate) AS Difference
FROM `MySQL Tutorial`.customer;
MySQL SYSDATE Function 4

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy