
- 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
Round seconds to nearest half minute in MySQL?
To round seconds to nearest half minute, use CEILING(). Let us first create a table −
mysql> create table DemoTable (secondValue int); Query OK, 0 rows affected (0.64 sec)
Example
Insert some records in the table using insert command −
mysql> insert into DemoTable values(27); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(56); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(118); Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+-------------+ | secondValue | +-------------+ | 27 | | 56 | | 118 | +-------------+ 3 rows in set (0.00 sec)
Following is the query to round seconds −
mysql> select secondValue, CEILING(secondValue / 30) / 2 AS ApproxMinutes from DemoTable;
Output
+-------------+---------------+ | secondValue | ApproxMinutes | +-------------+---------------+ | 27 | 0.5000 | | 56 | 1.0000 | | 118 | 2.0000 | +-------------+---------------+ 3 rows in set (0.00 sec)
- Related Articles
- How to round down to nearest integer in MySQL?
- Round off 1120 to nearest hundred.
- How to round off to nearest thousands?
- Round to nearest integer towards zero in Python
- How to round off numbers In nearest $100$.
- Round off to the nearest thousand.$5914$
- Round off 4200 to the nearest thousands.
- How to round to the nearest hundred in R?
- How to round up to the nearest N in JavaScript
- $231546 div 45$ round off to nearest 10.
- How to round off the numbers nearest tens?
- 439+334+4,317. Round off to nearest thousand
- We have to round off 42 to nearest 10s
- Round a number to the nearest even number in C#
- Round number down to nearest power of 10 JavaScript

Advertisements