Tutorial Gateway

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

MySQL NOW Function

by suresh

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

The basic syntax of the NOW() Function in MySQL is as shown below:

NOW();

MySQL NOW function Example

The following query shows you the basic use of this now function to get the current date and time.

SELECT NOW();

OUTPUT

MySQL Now Example 1

As you can see from the above screenshot, it returns today’s date and Time in YYYY-MM-DD HH:MM:SS format. Let us see another MySQL example with Alias Name.

SELECT NOW() AS 'Todays date and Time';

OUTPUT

MySQL Now Example 2

The following Date Function query explains to you what happens when we add value to this now function.

SELECT NOW() + 5;

SELECT NOW(), NOW() + 5;

OUTPUT

MySQL Now Example 4

From the above screenshot, it added those values to the current date and time. I mean, seconds to current date and time. Next, it is displaying the date in YYYYMMDDHHMMSS string format

MySQL NOW Example 2

In this example, we show you how to use this Now function on columns. Here, we are using a datediff function to find the difference between now and the Hire Date column value.

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

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

OUTPUT

MySQL Now Example 5

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
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy