zoukankan      html  css  js  c++  java
  • SQLite一些函数用法

    --格林威治日期时间,比北京时间晚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','localtime','start of month');
    
    --下月1号
    select date('now','localtime','start of month','+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','now','localtime') as int) >= 6 and cast(strftime('%H','now','localtime') as int) <=12  then '上午'  
    when cast(strftime('%H','now','localtime') as int) >12 and cast(strftime('%H','now','localtime') as int) <=18  then '下午' 
    when cast(strftime('%H','now','localtime') as int) >18 and cast(strftime('%H','now','localtime') as int) <=23  then '晚上'   
    else '凌晨' end; 
    
  • 相关阅读:
    Canvas文本绘制
    Canvas贝塞尔三级曲线
    Canvas贝塞尔二级曲线
    Canvas arcTo绘制圆弧
    mybatis springmvc调用oracle存储过程,返回记录集
    java调用oracle存储过程,返回结果集
    oracle存储过程返回结果集
    存储过程变量类型定义与表字段一致
    HTML5获取当前的经纬度坐标
    实现精灵沿着圆形轨迹运动
  • 原文地址:https://www.cnblogs.com/gdjlc/p/5438983.html
Copyright © 2011-2022 走看看