Learn Python
Learn Data Structure & Algorithm
Learn Numpy
Learn Pandas
Learn Matplotlib
Learn Seaborn
Learn Statistics
Learn Math
Learn MATLAB
Learn Machine learning
Learn Github
Learn OpenCV
Learn Deep Learning
MySQL Introduction
MySQL Setup
MySQL Operators
MySQL Basic Works
MySQL Create Table
MySQL insert and get values
MySQL Condition
MySQL GROUP BY
MySQL Case
MySQL sorting and calculate avg,sum,count
MySQL Update
MySQL Time
MySQL String
MySQL Rollback & Commit
MySQL Join and Concatenate
MySQL Index
MySQL Date
MySQL View
MYSQL With Python
Learn MongoDB
Learn Web scraping
Learn Excel
Learn Power BI
Learn Tableau
Learn Docker
Learn Hadoop
Suppose you have a database name database and inside that, you have a table named DataBaseTable which has a
date_time column. In the date column, you have date and time.
This function will show the server's current time.
This function will show the server's current time and date.
If you pass date and time then this function will return you only the time.
If you pass date and time or only time then this function will return you only the hour.
If you pass date and time then this function will return you only the minute.
If you pass date and time then this function will return you only the second.
If you pass two different times then this function will return the difference between those two times.
If you pass time and an interval then this function will add the interval time with the given time and will return you a new time.
If you pass time and an interval then this function will subtract interval time from the given time will return a new time.
This function will create a new time.To do this pass three parameters.First is for hours, then minute and second.
Time format is divided into four parts:
Hour:For hour you have four options:
%h-->It will show hours from 1 to 12. After 12 it will show 1. It will add
0 before one digit hour.
%H-->It will show hours from 1-24. It will add a 0 before one digit hour.
%g-->It will show hours from 1 to 12. After 12 it will show 1. It will not add
0 before one digit hour.
%G-->It will show hours from 1-24.It will not add add 0 before one digit hour.
Minutes:For minutes write %i
Seconds:For seconds write %s
Microseconds: For microseconds write %f
For AM and PM write %P
Let's see example:
SELECT TIME_FORMAT("10:05:10","%H %i %s") AS time;
SELECT TIME_FORMAT("10:05:10","%H:%i:%s %p") AS time;
You can use anything as a separator like /,-,: etc.