Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs
  • MySQL

MySQL SUBTIME Function

MySQL SUBTIME function is one of the Date Functions, used to subtract time from existing DateTime or Time expression. The syntax of the SUBTIME Function in MySQL is as shown below:

SUBTIME(DateTime1 or Time_Expression1, Time_Expression2);

The SUBTIME function Subtracts the Time_Expression2 value from the DateTime1 or Time_Expression1.

MySQL SUBTIME function Example

The following are the list examples that help you understand the use of this MySQL SUB TIME function.

In this Date Function example, First, we are subtracting 2 Hours, 10 Minutes, and 12 Seconds from the time expression 10:11:22. Next, we are subtracting the time along with Microseconds.

SELECT SUBTIME('10:11:22', '2:10:12');

SELECT SUBTIME('10:11:22', '04:09:12.111222');

SELECT SUBTIME('10:11:22.999888', '04:09:12.111222');
MySQL SUBTIME Function 1

In this MySQL Sub Time function example, we subtracted 10 Hours, 09 Minutes, 12 Seconds, and 111222 Microseconds. Next, we subtracted 100 Hours and 1000 Hours. The impact of subtracting these many hours (100 and 1000) changes the value of the MySQL date too.

SELECT SUBTIME('2019-02-28 23:59:59.999888', '10:09:12.111222');

SELECT SUBTIME('2019-02-28 23:59:59.999888', '100:09:12.111222');

SELECT SUBTIME('2019-02-28 23:59:59', '1000:09:12');
MySQL SUBTIME Function 2

Filed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions

Copyright © 2021ยท All Rights Reserved by Suresh.
About | Contact | Privacy Policy