mysql 函数

Last updated on November 20, 2024 am

🧙 Questions

☄️ Ideas

string转date

select str_to_date('2020-12-01 12:12:12','%Y-%m-%d %H:%i:%s') from dual

date转string

select date_format(now(),'%Y-%m-%d %H:%i:%s') from dual

date转为天数

select cast((unix_timestamp(now()) / 60 / 60 / 24) as signed) from dual;

时间格式

Specifier Description
%H/%k Hour (00..23)
%d Day of the month, numeric (00..31)
%e Day of the month, numeric (0..31)
%h/%I/%l Hour (01..12)
%i Minutes, numeric (00..59)
%j Day of year (001..366)
%M Month name (January..December)
%m Month, numeric (00..12)
%S/%s Seconds (00..59)
%T Time, 24-hour (hh:mm:ss)
%Y Year, numeric, four digits
%y Year, numeric (two digits)

日期加时间

当前时间加一天
select DATE_ADD(now(), INTERVAL 1 DAY) from dual

mysql 函数
https://ispong.isxcode.com/db/mysql/mysql 函数/
Author
ispong
Posted on
March 10, 2021
Licensed under