当前位置:网站首页>Date time functions commonly used in MySQL
Date time functions commonly used in MySQL
2022-07-28 23:05:00 【bhegi_ seg】
Catalog
6. Formatting of date and time
1. date (date) function
** Return current date :**CURDATE(), CURRENT_DATE(), CURRENT_DATE

2. Time (time) function
** Return current time :**CURTIME(), CURRENT_TIME(), CURRENT_TIME

3. Date and time functions
** Returns the current date and time :**CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP, LOCALTIME(), LOCALTIME, LOCALTIMESTAMP(), LOCALTIMESTAMP, NOW(), SYSDATE()

NOW(), SYSDATE() The difference between :
NOW() Return to execute the current SQL The time of the statement :

SYSDATE() Returns the time when the current function is executed :

SYSDATE() You can pass in a parameter :fsp Indicates whether decimal second precision is included (0~6 position )

4. Date and time comparison

The output of the above three statements is the same .
Mysql You can directly compare the time size with the string in , As long as your date format is legal .
5. Date and time calculation
**DATE_ADD() function :** Date and time increase and decrease
Function INTERVAL A positive value after the parameter indicates that the date time increases , A negative value indicates that the date time decreases

**DATEDIFF() function :** Calculate the difference between two dates

**TIMEDIFF() function :** Calculate two time differences

6. Formatting of date and time
DATE_FORMAT(date,format) function :
Commonly used :DATE_FORMAT(SYSDATE(),‘%Y-%m-%d %H:%i:%s’)
%p:PM or AM;
%r:HH:mm:ss PM Form time ;
%W: Zhou , Zhou Ming , Such as Tuesday;
%w: Zhou ,0-6,0 It's Sunday ;
%j: The number of days in the year in which the current date is located ,3 position (001-366).




DATE_FORMAT(date,format) and STR_TO_DATE(str,format) function :
DATE_FORMAT(date,format): In the database date The data is formatted as String type
STR_TO_DATE(str,format): Converts the string in the specified time format into DATETIME Type value .str To work with format Keep the format consistent , Otherwise, an error will be reported .

The first return value is String type , The second return value is datetime type .
**YEAR() function :** Take the year of the date and time

边栏推荐
- 定了!哪吒S全系产品将于7月31日上市发售
- cnpm安装步骤
- 《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》
- MySQL Basics - Introduction and basic instructions
- Morphology of image
- Introduction to structure
- Target detection notes fast r-cnn
- 【复制】互联网术语、简称、缩写
- Thesis reading (1) - zfnet of classification
- 简单的es高亮实战
猜你喜欢

Target detection notes -yolo

《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》

Paper reading: deep forest / deep forest /gcforest

【物理应用】水下浮动风力涡轮机的尾流诱导动态模拟风场附matlab代码

can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to host memory

Xshell7, xftp7 personal free version official download, no need to crack, no activation, download and use

RouYi-Cloud平台 ---项目的启动、登录功能是怎么实现的、怎么样创建新模块

Improvement 17 of yolov5: cnn+transformer -- integrating bottleneck transformers
![CS flow [abnormal detection: normalizing flow]](/img/54/0ac2926d5be8765c22fe6f3eb97769.png)
CS flow [abnormal detection: normalizing flow]

Servlet的使用手把手教学(一)
随机推荐
Will Qualcomm and MediaTek chips soon be sold, and will they surpass Huawei to become the first in China?
Record a question about the order of trigonometric function exchange integrals
【MySQL系列】 MySQL表的增删改查(进阶)
ValueError: Using a target size (torch.Size([64])) that is different to the input size (torch.Size([
今年联发科5G芯片出货有望达到5000万套!
The tenth improvement of yolov5: the loss function is improved to Siou
软件测试工具fiddler postman jmeter charlse核心功能总结
Summary of common formula notes for solving problems in Higher Mathematics
(important) first knowledge of C language -- function
No code development platform management background tutorial
2020年国内十大IC设计企业曝光!这五大产业挑战仍有待突破!
C语言学习内容总结
Invest 145billion euros! EU 17 countries announce joint development of semiconductor technology
Target detection notes - overview and common data sets
Improvement 18 of yolov5: the loss function is improved to alpha IOU loss function
Yolov5 improvement 12: replace backbone network C3 with lightweight network shufflenetv2
OSV_ q Expected all tensors to be on the same device, but found at least two devices, cuda:0
pg_rman的安装与使用《postgresql》
Recurrent neural network (RNN)
歌尔股份与上海泰矽微达成长期合作协议!专用SoC共促TWS耳机发展