TechBeamersTechBeamers
  • Learn ProgrammingLearn Programming
    • Python Programming
      • Python Basic
      • Python OOP
      • Python Pandas
      • Python PIP
      • Python Advanced
      • Python Selenium
    • Python Examples
    • Selenium Tutorials
      • Selenium with Java
      • Selenium with Python
    • Software Testing Tutorials
    • Java Programming
      • Java Basic
      • Java Flow Control
      • Java OOP
    • C Programming
    • Linux Commands
    • MySQL Commands
    • Agile in Software
    • AngularJS Guides
    • Android Tutorials
  • Interview PrepInterview Prep
    • SQL Interview Questions
    • Testing Interview Q&A
    • Python Interview Q&A
    • Selenium Interview Q&A
    • C Sharp Interview Q&A
    • PHP Interview Questions
    • Java Interview Questions
    • Web Development Q&A
  • Self AssessmentSelf Assessment
    • Python Test
    • Java Online Test
    • Selenium Quiz
    • Testing Quiz
    • HTML CSS Quiz
    • Shell Script Test
    • C/C++ Coding Test
Search
  • Python Multiline String
  • Python Multiline Comment
  • Python Iterate String
  • Python Dictionary
  • Python Lists
  • Python List Contains
  • Page Object Model
  • TestNG Annotations
  • Python Function Quiz
  • Python String Quiz
  • Python OOP Test
  • Java Spring Test
  • Java Collection Quiz
  • JavaScript Skill Test
  • Selenium Skill Test
  • Selenium Python Quiz
  • Shell Scripting Test
  • Latest Python Q&A
  • CSharp Coding Q&A
  • SQL Query Question
  • Top Selenium Q&A
  • Top QA Questions
  • Latest Testing Q&A
  • REST API Questions
  • Linux Interview Q&A
  • Shell Script Questions
© 2024 TechBeamers. All Rights Reserved.
Reading: MySQL CURRENT_TIMESTAMP() Function
Font ResizerAa
TechBeamersTechBeamers
Font ResizerAa
  • Python
  • SQL
  • C
  • Java
  • Testing
  • Selenium
  • Agile Concepts Simplified
  • Linux
  • MySQL
  • Python Quizzes
  • Java Quiz
  • Testing Quiz
  • Shell Script Quiz
  • WebDev Interview
  • Python Basic
  • Python Examples
  • Python Advanced
  • Python OOP
  • Python Selenium
  • General Tech
Search
  • Programming Tutorials
    • Python Tutorial
    • Python Examples
    • Java Tutorial
    • C Tutorial
    • MySQL Tutorial
    • Selenium Tutorial
    • Testing Tutorial
  • Top Interview Q&A
    • SQL Interview
    • Web Dev Interview
  • Best Coding Quiz
    • Python Quizzes
    • Java Quiz
    • Testing Quiz
    • ShellScript Quiz
Follow US
© 2024 TechBeamers. All Rights Reserved.
MySQL Tutorial

MySQL CURRENT_TIMESTAMP() Function

Last updated: Oct 05, 2023 12:47 pm
By Meenakshi Agarwal
Share
3 Min Read
MySQL CURRENT_TIMESTAMP() Function with examples
MySQL CURRENT_TIMESTAMP() Function with examples
SHARE

This tutorial explains how to use the MySQL CURRENT_TIMESTAMP() function with the help of examples. By using it, you can convert or display the current date and time.

Contents
SyntaxCURRENT_TIMESTAMP() ExamplesString contextNumeric contextFractional Seconds PrecisionSummary – MySQL CURRENT_TIMESTAMP()

The output format is either ‘YYYY-MM-DD HH:MM: SS’ format or YYYYMMDDHHMMSS, which depends on the context of the calling function, whether it is numeric or string. The function NOW() and CURRENT_TIMESTAMP() are equivalent to the CURRENT_TIMESTAMP.

Please note that the examples shown here will give results depending on the present date.

MySQL CURRENT_TIMESTAMP()

This function provides a date and time value formatted in a ‘YYYY-MM-DD HH:MM: SS’ style. It is supported in various MySQL versions such as 3.23, 4.0, 4.4, 5.6, 5.7, and so on.

Syntax

It comes in the following forms:

-- MySQL CURRENT_TIMESTAMP functions
CURRENT_TIMESTAMP();
CURRENT_TIMESTAMP(FSP);

The argument, FSP in the second form, represents the fractional seconds precision for the resultant value. If you want more precision in time value, then use the 2nd format.

Let’s now go through some of the examples using the MySQL CURRENT_TIMESTAMP() function.

We think that the following topics would even help more with this tutorial:

  • MySQL TIMESTAMP
  • MySQL Date and Date Functions

CURRENT_TIMESTAMP() Examples

String context

In this example, we are printing the current timestamp value in the string context.

-- String context
SELECT CURRENT_TIMESTAMP();

The above MySQL statement would produce the date in standard string format. Check below:

-- Output
'2019-09-05 17:40:20'

Numeric context

Check this example of using the CURRENT_TIMESTAMP() method in a numeric context.

-- Numeric context
SELECT CURRENT_TIMESTAMP() + 0;
SELECT CURRENT_TIMESTAMP() + 1;

The above MySQL statements would produce the date in standard string format. Check below:

-- Output
20190905174020
20190905174021

Fractional Seconds Precision

In this example, we are passing the FSP value to set the fractional seconds precision in the result.

-- Fractional Seconds Precision
SELECT CURRENT_TIMESTAMP(5);

Also Read: MySQL FROM_UNIXTIME() Function

The output is as follows:

-- Output
'2019-09-05 17:40:54.22207'

Summary – MySQL CURRENT_TIMESTAMP()

We hope you should now feel comfortable using the MySQL CURRENT_TIMESTAMP() function. However, you can take up more examples and practice.

Also, to learn SQL from scratch to depth, read our step-by-step MySQL tutorial.

You Might Also Like

MySQL vs MongoDB Comparison

Concatenate Strings in an SQL Query With Examples

The Difference between UPSERT & Insert

SQL Programming Test in 2024

SQL Table Creation: The Missing Manual

Meenakshi Agarwal Avatar
By Meenakshi Agarwal
Follow:
Hi, I'm Meenakshi Agarwal. I have a Bachelor's degree in Computer Science and a Master's degree in Computer Applications. After spending over a decade in large MNCs, I gained extensive experience in programming, coding, software development, testing, and automation. Now, I share my knowledge through tutorials, quizzes, and interview questions on Python, Java, Selenium, SQL, and C# on my blog, TechBeamers.com.
Previous Article MySQL vs PostgreSQL Comparison MySQL vs PostgreSQL Comparison
Next Article Python multiline string simplified with examples How to Use Multiline Strings in Python

Popular Tutorials

SQL Interview Questions List
50 SQL Practice Questions for Good Results in Interview
SQL Interview Nov 01, 2016
Demo Websites You Need to Practice Selenium
7 Sites to Practice Selenium for Free in 2024
Selenium Tutorial Feb 08, 2016
SQL Exercises with Sample Table and Demo Data
SQL Exercises – Complex Queries
SQL Interview May 10, 2020
Java Coding Questions for Software Testers
15 Java Coding Questions for Testers
Selenium Tutorial Jun 17, 2016
30 Quick Python Programming Questions On List, Tuple & Dictionary
30 Python Programming Questions On List, Tuple, and Dictionary
Python Basic Python Tutorials Oct 07, 2016
//
Our tutorials are written by real people who’ve put in the time to research and test thoroughly. Whether you’re a beginner or a pro, our tutorials will guide you through everything you need to learn a programming language.

Top Coding Tips

  • PYTHON TIPS
  • PANDAS TIPSNew
  • DATA ANALYSIS TIPS
  • SELENIUM TIPS
  • C CODING TIPS
  • GDB DEBUG TIPS
  • SQL TIPS & TRICKS

Top Tutorials

  • PYTHON TUTORIAL FOR BEGINNERS
  • SELENIUM WEBDRIVER TUTORIAL
  • SELENIUM PYTHON TUTORIAL
  • SELENIUM DEMO WEBSITESHot
  • TESTNG TUTORIALS FOR BEGINNERS
  • PYTHON MULTITHREADING TUTORIAL
  • JAVA MULTITHREADING TUTORIAL

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Loading
TechBeamersTechBeamers
Follow US
© 2024 TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use
TechBeamers Newsletter - Subscribe for Latest Updates
Join Us!

Subscribe to our newsletter and never miss the latest tech tutorials, quizzes, and tips.

Loading
Zero spam, Unsubscribe at any time.
x