当前位置:网站首页>Precautions for using timestamp type of SQLite3 database
Precautions for using timestamp type of SQLite3 database
2022-06-22 01:12:00 【Silent starry sky】
Sqlite3 Database timestamp Precautions for the use of types
stay Sqlite3 Can be used in timestamp The timestamp type records the time , But in the course of use, we found several places that were easy to be damaged , Make a note of .
1. Date time format
Whether it's a query or an insert , about timestamp Field rule SQL The date time format in the statement must be like this :“yyyy-MM-dd HH:mm:ss”. such as :“2022-06-09 10:00:00”, That's right , But it can't be written as ”2022-6-9 10:0:0“. No result can be found after the error is written .
2.timestamp Queries must go through local time conversion , Otherwise, the query time is wrong , For example, to query from 2022-6-19 10:0:0 To 2022-6-19 15:0:0 The second record is Where The sentence should be written like this :
WHERE DateTime(HisTime,‘localtime’) >= DateTime(‘2022-06-19 10:00:00’,‘localtime’) AND DateTime(HisTime,‘localtime’) <= DateTime(‘2022-06-19 15:00:00’,‘localtime’)
There's another way , This is to set the initial value when creating a field :DEFAULT (datetime(‘now’,‘localtime’)), The local time is used as the initial value of the field , You can insert a record without inserting this time field , The database engine will initially set the local current time .
Here are a few main things to note , Prevent errors next time .
边栏推荐
- The next goal of digital transformation: providing just in time information
- 让人无法喜爱的STL
- Rotating frame target detection -- about the definition and solution of rotating frame
- Pytorch learning 10: statistical operations
- 【DailyFresh】课程记录
- [dailyfresh] course record
- Broadening - simple strategy test
- 4275. Dijkstra序列
- 消息队列之取消会议和自动退款处理
- pytorch学习13:实现LetNet和学习nn.Module相关基本操作
猜你喜欢

SSO and oauth2 solutions

Pytorch learning 10: statistical operations

【DailyFresh】课程记录

12 initialization of beautifulsoup class

Special survey of moving average strategy

yolov3 3D 语义点云paper阅读
![[examination skills] memory method and simple derivation of Green formula](/img/26/f28a9f4abaca94988845b3fdaaf571.png)
[examination skills] memory method and simple derivation of Green formula

pytorch学习12:自动求导

2. add two numbers
![Chapter VIII exercises (45A) [microcomputer principles] [exercises]](/img/79/8311a409113331e72f650a83351b46.png)
Chapter VIII exercises (45A) [microcomputer principles] [exercises]
随机推荐
[project construction] cmake create release and debug projects
pytorch学习03:张量数据类型和一些操作
Special survey of moving average strategy
52类110 个常用的组件和框架
Rotating frame target detection -- about the definition and solution of rotating frame
Status code summary
3746. 牛的学术圈 II
Pytorch learning 10: statistical operations
4273. 链表合并
消息队列之取消会议和自动退款处理
旋转框目标检测————关于旋转框定义和解决方案
[redis] install redis in Ubuntu and the basic usage and configuration of redis
【环境踩坑】用opencv打开图片时报错
03 FastJson 解决循环引用
SQL语句——数据更新、修改、删除
Pytorch learning 06: tensor dimension transformation
pytorch学习05:索引和切片
The importance of rational selection of seal clearance of hydraulic slip ring
HDOJ - Is It A Tree?
【环境踩坑】pycharm使用qt时报错