
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
MySQL format time with lowercase am/pm?
To format MySQL time with lowercase am/pm, use the LOWER() as well as DATE_FORMAT().Let us first create a table −
mysql> create table formatTime -> ( -> LoginTime time -> ); Query OK, 0 rows affected (0.56 sec)
Following is the query to insert records in the table using insert command −
mysql> insert into formatTime values('12:40:34'); Query OK, 1 row affected (0.20 sec) mysql> insert into formatTime values('14:10:58'); Query OK, 1 row affected (0.13 sec) mysql> insert into formatTime values('16:56:40'); Query OK, 1 row affected (0.18 sec) mysql> insert into formatTime values('10:12:14'); Query OK, 1 row affected (0.16 sec)
Following is the query to display all records from the table using select statement −
mysql> select * from formatTime;
This will produce the following output −
+-----------+ | LoginTime | +-----------+ | 12:40:34 | | 14:10:58 | | 16:56:40 | | 10:12:14 | +-----------+ 4 rows in set (0.00 sec)
Following is the query to format MySQL time with lowercase am/pm −
mysql> select LOWER(DATE_FORMAT(LoginTime,'%l:%i %p')) from formatTime;
This will produce the following output −
+------------------------------------------+ | LOWER(DATE_FORMAT(LoginTime,'%l:%i %p')) | +------------------------------------------+ | 12:40 pm | | 2:10 pm | | 4:56 pm | | 10:12 am | +------------------------------------------+ 4 rows in set (0.04 sec)
- Related Articles
- Format MySQL CURRENT_TIMESTAMP to AM & PM?
- Java Program to Format time in AM-PM format
- How to sort time in AM/ PM in MySQL?
- Display AM/PM time marker with SimpleDateFormat(“a”) in Java
- Convert PHP variable “11:00 AM” to MySQL time format?
- How do you display JavaScript datetime in 12hour AM/PM format?
- Display hour in h (1-12 in AM/PM) format in Java
- Display hour in hh (01-12 in AM/PM) format in Java
- Java Program to display hour in K (0-11 in AM/PM) format
- AM and PM Full Form (AM Full Form (Anti Meridiem, PM Full Form (Post Meridiem)
- Java Program to display hour and minute in AM or PM
- Retrieve time from MySQL as HH:MM format?
- Format time with DateFormat.SHORT in Java
- Format time with DateFormat.FULL in Java
- Java Program to format time with DateFormat.MEDIUM

Advertisements