Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • 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

MySQL LOCALTIMESTAMP

MySQL LOCALTIMESTAMP or Localtimestamp() are the two Date Functions, used to return the current date & time in YYYY-MM-DD HH:MM:SS. The basic syntax of the local timestamp in MySQL is as shown below:

LOCALTIMESTAMP;

LOCALTIMESTAMP();

MySQL LOCALTIMESTAMP Example

The following statements show you how to use these MySQL local timestamp functions.

TIP: Both these local timestamp Date Functions are the synonyms of the NOW function. All these three MySQL functions return the same output.

SELECT LOCALTIMESTAMP;

SELECT LOCALTIMESTAMP();

SELECT NOW();
MySQL LOCALTIMESTAMP Function 1

As you can see from the above, the three statements return the local date and time stamp in YYYY-MM-DD HH:MM:SS format. The below statements show what happens when adding a few seconds or random value to the MySQL localtimestamp() function.

SELECT LOCALTIMESTAMP, LOCALTIMESTAMP + 22;

SELECT LOCALTIMESTAMP(), LOCALTIMESTAMP() + 15;

SELECT DATEDIFF(LOCALTIMESTAMP(), '2019-01-01');
MySQL LOCALTIMESTAMP Function 2

From the above screenshot, you can see the function added those extra seconds and displaying the date in YYYYMMDDHHMMSS string format. Within the last statement, we used the Datediff function to find the difference between the local timestamp and the custom date ‘2019-01-01.’

Filed 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 | Contact | Privacy Policy