时间函数
NOW()/ CURRENT_TIMESTAMP()
CURRENT_DATE()/curdate()
CURRENT_TIME()
UNIX_TIMESTAMP()
FROM_UNIXTIME(UNIX_TIMESTAMP())
UNIX_TIMESTAMP('2020-01-01')
weekday('2020-01-01')
week('2020-01-01')
dayofyear('2020-01-01')
DATE_FORMAT('2021-01-01 08:30:50','%Y-%m-%d %H:%i:%s')
str_to_date('2021-01-01 08:30:50','%Y-%m-%d %H:%i:%s')
DATE_ADD('2021-02-02',INTERVAL 1 day)
DATE_SUB('2021-02-02',INTERVAL 1 day)
DATEDIFF('2021-01-02','2021-01-01')
TIMESTAMPDIFF(hour, '2021-01-01 08:30:00', '2021-01-02 10:30:00')
select date_add(curdate(),interval -day(curdate())+1 day)
last_day('2020-01-01')
select DATEDIFF(date_add(curdate()-day(curdate())+1,interval 1 month ),DATE_ADD(curdate(),interval -day(curdate())+1 day)) from dual
select date_add(curdate() - day(curdate()) +1,interval 1 month );
select date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval extract(
day from now())-1 day),interval 1 month)
select date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval extract(
day from now()) day),interval 0 month)
select date_add(curdate()-day(curdate())+1,interval 1 month);
select last_day(date_sub(now(),interval -1 month));
字符串函数
ascii(x)
strcmp(x,y)
char_length(x)
concat(x1,x2)
insert(x,index,len,y)
replace(x,a,b)
lower
upper
left(x,n)
right(x,n)
lpad(x,len,y)
rpad(x,len,y)
trim(x)
trim(x from y)
repeat(x,n)
space(n)
instr(x,y)/locate(x,y)
substring(x,index,len)
substring_index(x,y,index)
elt(n,x1,x2...)
field(x,x1,x2...)
find_in_set(x,y)
reverse(x)
数值函数
abs(x)
sign(x)
pi()
ceil(x)/ceiling(x)
floor()
round(x,y)
least(x,y)
greatest(x,y)
mod(x,y)
rand()
truncate(x,y)
sqrt(x)
radians(x)
degrees(x)
sin(x)
asin(x)
cos(x)
acos(x)
tan(x)
atanx(x)
atan2(x,y)
cot(x)