Collections:
TIME_FORMAT() - Formatting Time
How to convert a time into formatted string using the TIME_FORMAT() function?
✍: FYIcenter.com
TIME_FORMAT(time, format) is a MySQL built-in function that converts a time into a formatted string. For example:
SELECT TIME_FORMAT(NOW(3), '%H:%i:%s.%f'); -- +------------------------------------+ -- | TIME_FORMAT(NOW(3), '%H:%i:%s.%f') | -- +------------------------------------+ -- | 20:58:42.648000 | -- +------------------------------------+
Reference information of the TIME_FORMAT() function:
TIME_FORMAT(time, format): str Formats the time value according to the format string. Arguments, return value and availability: time: Required. The time value to be formatted. format: Required. The string with time format specifiers. str: Return value. The formatted time Available since MySQL 4. Time format specifiers: Specifier Description --------- ----------- %f Microseconds (000000..999999) %H Hour (00..23) %h Hour (01..12) %I Hour (01..12) %i Minutes, numeric (00..59) %k Hour (0..23) %l Hour (1..12) %p AM or PM %r Time, 12-hour (hh:mm:ss followed by AM or PM) %S Seconds (00..59) %s Seconds (00..59) %T Time, 24-hour (hh:mm:ss) %% A literal % character %x x, for any “x” not listed above
⇒ TIME_TO_SEC() - Converting Time to Seconds
⇐ TIMESTAMPDIFF() - Difference in Timestamp Component
2023-11-17, 256🔥, 0💬
Popular Posts:
How to run Queries with SQL Server Management Studio Express in SQL Server? 1. Launch and connect SQ...
Can Date and Time Values Be Converted into Integers in SQL Server Transact-SQL? Can date and time va...
How To Convert Character Strings into Numeric Values in SQL Server Transact-SQL? Sometimes you need ...
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, y...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...