🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 函数 随机数 rand() 连接字符串 concat('中国','打日本') 转换小写 lcase('ABC') lower 转换大写 upper ucase 去除空格 trim(str) ``` <pre class="calibre14">``` <span class="token1">curdate</span><span class="token2">(</span><span class="token2">)</span><span class="token">+</span><span class="token3">0</span> 返回<span class="token3">20160916</span> <span class="token1">curdate</span><span class="token2">(</span><span class="token2">)</span> <span class="token3">2016</span><span class="token">-</span><span class="token3">09</span><span class="token">-</span><span class="token3">16</span> <span class="token1">curtime</span><span class="token2">(</span><span class="token2">)</span> <span class="token3">21</span><span class="token2">:</span><span class="token3">53</span><span class="token2">:</span><span class="token3">23</span> <span class="token1">now</span><span class="token2">(</span><span class="token2">)</span> <span class="token3">2019</span><span class="token">-</span><span class="token3">07</span><span class="token">-</span><span class="token3">10</span> <span class="token3">21</span><span class="token2">:</span><span class="token3">52</span><span class="token2">:</span><span class="token3">23</span>日期时间 <span class="token1">unix_timestamp</span><span class="token2">(</span><span class="token1">now</span><span class="token2">(</span><span class="token2">)</span><span class="token2">)</span> 返回时间戳 <span class="token3">1562767275</span> <span class="token1">from_unixtime</span><span class="token2">(</span> <span class="token3">1539659520</span><span class="token2">)</span> 返回 <span class="token3">2018</span><span class="token">-</span><span class="token3">10</span><span class="token">-</span><span class="token3">16</span> <span class="token3">11</span><span class="token2">:</span><span class="token3">12</span><span class="token2">:</span><span class="token3">00</span> <span class="token1">from_unixtime</span><span class="token2">(</span><span class="token3">1515980716</span><span class="token2">,</span> <span class="token4">'%Y-%m-%d %H:%i:%S'</span><span class="token2">)</span> <span class="token3">2018</span><span class="token">-</span><span class="token3">01</span><span class="token">-</span><span class="token3">15</span> <span class="token3">09</span><span class="token2">:</span><span class="token3">45</span><span class="token2">:</span><span class="token3">16</span> 格式化时间 <span class="token1">date_format</span><span class="token2">(</span><span class="token1">now</span><span class="token2">(</span><span class="token2">)</span><span class="token2">,</span> <span class="token4">'%Y-%m-%d'</span><span class="token2">)</span> <span class="token3">2018</span><span class="token">-</span><span class="token3">01</span><span class="token">-</span><span class="token3">15</span> <span class="token1">date</span><span class="token2">(</span> <span class="token1">now</span><span class="token2">(</span><span class="token2">)</span><span class="token2">)</span> <span class="token3">2019</span><span class="token">-</span><span class="token3">07</span><span class="token">-</span><span class="token3">10</span> 提取日期 <span class="token1">year</span><span class="token2">(</span><span class="token4">'2019-7-10'</span><span class="token2">)</span> 返回<span class="token3">2019</span> <span class="token1">month</span><span class="token2">(</span><span class="token4">'2016-04-28'</span><span class="token2">)</span> <span class="token3">4</span> <span class="token1">day</span><span class="token2">(</span><span class="token1">now</span><span class="token2">(</span><span class="token2">)</span><span class="token2">)</span> <span class="token3">11</span> 返回天 <span class="token1">hour</span><span class="token2">(</span><span class="token4">'2019-12-6 14:7:50'</span><span class="token2">)</span> <span class="token3">14</span> <span class="token1">minute</span><span class="token2">(</span><span class="token4">'2019-12-6 14:7:50'</span><span class="token2">)</span> <span class="token3">7</span> <span class="token1">second</span><span class="token2">(</span><span class="token4">'2019-12-6 14:7:50'</span><span class="token2">)</span> <span class="token3">50</span> <span class="token1">last_day</span><span class="token2">(</span><span class="token4">'2019-12-6 14:7:50'</span><span class="token2">)</span> <span class="token3">2019</span><span class="token">-</span><span class="token3">12</span><span class="token">-</span><span class="token3">31</span> 给定日期最后一天 <span class="token1">quarter</span><span class="token2">(</span><span class="token4">'2016-04-28'</span><span class="token2">)</span> <span class="token3">2</span> 季度<span class="token2">,</span><span class="token3">1</span><span class="token2">,</span><span class="token3">2</span><span class="token2">,</span><span class="token3">3</span><span class="token2">,</span><span class="token3">4</span> <span class="token1">dayofweek</span><span class="token2">(</span><span class="token4">'2019-7-10'</span><span class="token2">)</span> 返回<span class="token3">4</span> 星期三 <span class="token">-</span><span class="token3">1</span> <span class="token1">weekday</span><span class="token2">(</span><span class="token4">'2019-7-10'</span><span class="token2">)</span> 返回<span class="token3">2</span> 星期三<span class="token">+</span><span class="token3">1</span> <span class="token1">dayofyear</span><span class="token2">(</span><span class="token4">'2019-7-10'</span><span class="token2">)</span> 返回今天是<span class="token3">191</span>天 <span class="token1">to_days</span><span class="token2">(</span><span class="token4">'2019-12-6 14:7:50'</span><span class="token2">)</span> <span class="token3">737764</span>计算日期 d 距离 <span class="token3">0000</span> 年 <span class="token3">1</span> 月 <span class="token3">1</span> 日的天数 <span class="token1">from_days</span><span class="token2">(</span><span class="token3">733627</span><span class="token2">)</span> <span class="token3">2008</span><span class="token">-</span><span class="token3">08</span><span class="token">-</span><span class="token3">08</span> 同上相反 <span class="token1">day</span><span class="token2">(</span><span class="token1">last_day</span><span class="token2">(</span><span class="token1">now</span><span class="token2">(</span><span class="token2">)</span><span class="token2">)</span><span class="token2">)</span> 返回本月天数 <span class="token1">date_add</span><span class="token2">(</span><span class="token4">'2019-12-6 14:7:50'</span><span class="token2">,</span>INTERVAL <span class="token3">1</span> day<span class="token2">)</span> <span class="token">+</span><span class="token3">1</span>天 <span class="token1">date_sub</span><span class="token2">(</span><span class="token4">'2019-12-6 14:7:50'</span><span class="token2">,</span>INTERVAL <span class="token3">1</span> day<span class="token2">)</span> <span class="token">-</span><span class="token3">1</span>天 <span class="token1">timestamp</span><span class="token2">(</span><span class="token4">'2008-08-08'</span><span class="token2">)</span> <span class="token3">2008</span><span class="token">-</span><span class="token3">08</span><span class="token">-</span><span class="token3">08</span> <span class="token3">00</span><span class="token2">:</span><span class="token3">00</span><span class="token2">:</span><span class="token3">00</span> ``` ``` 版本version 聚合函数 avg(col) 平均值 count(\*) 记录数 min(col) max(col)最小 最大值 sum(col)求和