Collections:
SYSDATE() - Current Timestamp
How to obtain the current timestamp using the SYSDATE() function?
✍: FYIcenter.com
SYSDATE(prec) is a MySQL built-in function that
returns the current timestamp with a given precision of fractional seconds.
For example:
SELECT SYSDATE(), SLEEP(2), SYSDATE(); -- +---------------------+----------+---------------------+ -- | SYSDATE() | SLEEP(2) | SYSDATE() | -- +---------------------+----------+---------------------+ -- | 2023-11-15 12:26:41 | 0 | 2023-11-15 12:26:43 | -- +---------------------+----------+---------------------+ SELECT SYSDATE(), SYSDATE()+1; -- +---------------------+----------------+ -- | SYSDATE() | SYSDATE()+1 | -- +---------------------+----------------+ -- | 2023-11-15 17:12:24 | 20231115171225 | -- +---------------------+----------------+ SELECT SYSDATE(6), SYSDATE(6)+1; -- +----------------------------+-----------------------+ -- | SYSDATE(6) | SYSDATE(6)+1 | -- +----------------------------+-----------------------+ -- | 2023-11-15 17:13:00.628785 | 20231115171301.634238 | -- +----------------------------+-----------------------+
Reference information of the SYSDATE() function:
SYSDATE(prec): tm Returns the current timestamp as a value in 'YYYY-MM-DD hh:mm:ss.SSSSSS' or YYYYMMDDhhmmss.SSSSSS format, depending on whether the function is used in string or numeric context. Arguments, return value and availability: prec: Optional. Default is 0. The precision of fractional seconds. tm: Return value. The current timestamp as a string or number. Available since MySQL 4.
Related MySQL functions:
⇐ SUBTIME() - Subtracting Time
2023-11-17, 981🔥, 0💬
Popular Posts:
What are binary literals supported in SQL Server Transact-SQL? Binary literals in Transact-SQL are s...
How to download and install the scaled-down database AdventureWorksLT in SQL Server? If you want to ...
Where to find answers to frequently asked questions on Storage Engines: MyISAM, InnoDB and BDB in My...
How To Generate Random Numbers with the RAND() Function in SQL Server Transact-SQL? Random numbers a...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...