当前位置:网站首页>sqlite 日期字段加一天
sqlite 日期字段加一天
2022-08-03 07:30:00 【木尧大兄弟】
背景介绍
需要写一个更改时间字段的功能,要用到 sql 语句操作 sqlite 数据库,由于 sqlite 不支持 dateadd 等函数,只能用其他方法,于是找到了 datetime()
函数。
使用方法
对 review
表的 add_time
字段统一增加 1天
,执行以下语句:
update review set add_time=DATETIME(add_time, ‘+1 day’);
执行前:
执行后:
扩展知识
SQLite 支持以下五个日期和时间函数:
date(timestring, modifier, modifier, ...)
以 YYYY-MM-DD 格式返回日期。time(timestring, modifier, modifier, ...)
以 HH:MM:SS 格式返回时间。datetime(timestring, modifier, modifier, ...)
以 YYYY-MM-DD HH:MM:SS 格式返回。julianday(timestring, modifier, modifier, ...)
这将返回从格林尼治时间的公元前 4714 年 11 月 24 日正午算起的天数。strftime(format, timestring, modifier, modifier, ...)
这将根据第一个参数指定的格式字符串返回格式化的日期。
上述五个日期和时间函数把时间字符串作为参数。时间字符串后跟零个或多个 modifier
修饰符。strftime()
函数也可以把格式字符串 format
作为其第一个参数。下面将为您详细讲解不同类型的时间字符串和修饰符。
参考:https://www.runoob.com/sqlite/sqlite-date-time.html
边栏推荐
猜你喜欢
随机推荐
JS作用对象API技巧
001-进程与线程
华为设备配置BFD状态与接口状态联动
boot - SSE
DSP-ADAU1452输出通道配置
Shell运维开发基础(一)
升级
剑指offer专项突击版第18天
Daily practice of PMP | Do not get lost in the exam-8.2 (including agility + multiple choice)
解决GANs训练中模式崩塌/训练崩溃的十五个方法
@Async注解的坑,小心
基于SSM开发的的小区物业管理系统小程序源码
pyspark df secondary sorting
Detailed explanation of cause and effect diagram of test case design method
如何像用自来水一样使用数据库?|腾讯云数据库TDSQL-C
STL - string
ViewModel 记录下 +
千万级别的表分页查询非常慢,怎么办?
postman将接口返回结果生成json文件到本地
The use of the database table structure document generation tool screw