请教一下,想每次批量处理提取的数据都是当前日期的数据,可以就是不能提取出来,也没有报错,就是不知道为什么
select date from worker where date=(select date('now'))
背景: 表:worker 字段:date 格式:2018/2/22
但是如果修改成 select date from worker where date=‘ 2018/2/22 ’ 这样就可以成功提取出来,用函数就不行了。
1
Dic4000 2018-02-22 18:16:54 +08:00
试试:select date from worker where date=Date('now')
|
2
alpenstock 2018-02-23 09:48:58 +08:00
sqlite date() 函数默认的格式是 2018-02-22,不是 2018/2/22
可以用 select date from worker where date=(select strftime('%Y/%m/%d','now')); 或者 select date from worker where date= strftime('%Y/%m/%d','now'); |
3
alpenstock 2018-02-23 09:52:31 +08:00
SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:
TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS"). REAL as Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar. INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC. 参考自 http://sqlite.org/datatype3.html |
4
andmspy OP 谢谢,谢谢。
|