加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SQLite一些函数用法

发布时间:2020-12-12 19:31:16 所属栏目:百科 来源:网络整理
导读:--格林威治日期时间,比北京时间晚8小时select datetime('now');--格林威治日期select date('now');--本地时间select time('now','localtime');--日期时间格式化select strftime('%Y-%m-%d %H:%M:%S','now','localtime');--加1小时select datetime(date('now
--格林威治日期时间,比北京时间晚8小时
select datetime('now');

--格林威治日期
select date('now');

--本地时间
select time('now','localtime');

--日期时间格式化
select strftime('%Y-%m-%d %H:%M:%S','now','localtime');

--加1小时
select datetime(date('now'),'+1 hour');

--加1小时30分钟
select datetime(date('now'),'+1 hour','+30 minute');

--当月最后一天
select date('now','localtime','start of month','+1 month','-1 day');

--当月1号
select date('now','start of month');

--下月1号
select date('now','+1 month');

--截取字符串(第2个参数为从1算起的开始位置,第3个位置为截取长度):结果为123
select substr('abc123',4,3);

--计算长度,结果为6
select length('abc123');

--返回小写、大写,结果为abc,ABC
select lower('abC'),upper('abC');

--四舍五入保留2位小数
select round(cast(1 as double)/cast(3 as double),2);

--case when用法
select
case 
when cast(strftime('%H','localtime') as int) >= 6 and cast(strftime('%H','localtime') as int) <=12  then '上午'  
when cast(strftime('%H','localtime') as int) >12 and cast(strftime('%H','localtime') as int) <=18  then '下午' 
when cast(strftime('%H','localtime') as int) >18 and cast(strftime('%H','localtime') as int) <=23  then '晚上'   
else '凌晨' end; 








(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读