Mysql 常用函式

2021-08-10 23:48:05 字數 918 閱讀 2476

select unix_timestamp();

-- 返回當前時間距離 1970-01-01 00:00:00 gmt 的秒數

select unix_timestamp('2017-01-01');

-- 返回引數時間距離 1970-01-01 00:00:00 gmt 的秒數

select from_unixtime(1483200000);

-- 根據 秒數(距離 1970-01-01 00:00:00 gmt 的秒數)返回日期

select time_to_sec('01:01:01');

-- 時間轉換秒

select sec_to_time(86400);

-- 秒轉換時間

select

current_timestamp();

-- 獲取當前時間戳

select date_format('2017-11-1901:10:10', '%y-%m-%d %h:%i:%s');

-- 日期轉字串(格式化)

select str_to_date('2017-11-19', '%y-%m-%d %h:%i:%s');

-- 字串轉日期

select str_to_date('08:09:30', '%h:%i:%s');

-- 字串轉時間

select date_add(now(), interval

1day);

-- 當前時間加一天(其他單位引數:hour, minute, second, microsecond, week, month, quarter, year)

select date_sub('2018-01-01 00:00:00', interval

1day);

-- 減去一天

mysql 常用函式迴圈 mysql 常用函式

mysql 常用函式 數字函式 ceiling x 返回大於x的最小整數值 floor x 返回小於x的最大整數值 truncate x,y 返回數字x截短為y位小數的結果 僅僅只是截斷,不會進行四捨五入計算 聚合函式 group concat col 返回由屬於一組的列值連線組合而成的結果 字串函...

mysql常用函式哪些 MySQL常用函式彙總

數學類函式 ceil x ceilin x 進一取整 floor x 捨掉小數部分 round x,y 四捨五入 保留y位小數 mod x,y x除以y以後的餘數 abs x 取x的絕對值 power x,y pow x,y 冪運算 x的y次冪 pi 圓周率 rand 或者rand x 0 1之間的...

mysql常用轉換函式 Mysql常用函式

ip位址轉換 inet aton 將ip位址轉換成數字型 inet ntoa 將數字型轉換成ip位址 phpip位址相互轉換 ip 轉整型 ip2long 133.114.56.135 轉整型後帶符號 2056111993 bindec decbin ip2long 133.114.56.135 轉...