SQLite日期函数示例

转自:http://www.sqlite.org/lang_datefunc.html

Examples

Compute the current date.

SELECT date('now');


Compute the last day of the current month.

SELECT date('now','start of month','+1 month','-1 day');


Compute the date and time given a unix timestamp 1092941466.

SELECT datetime(1092941466, 'unixepoch');


Compute the date and time given a unix timestamp 1092941466, and compensate for your local timezone.

SELECT datetime(1092941466, 'unixepoch', 'localtime');


Compute the current unix timestamp.

SELECT strftime('%s','now');


Compute the number of days since the signing of the US Declaration of Independence.

SELECT julianday('now') - julianday('1776-07-04');


Compute the number of seconds since a particular moment in 2004:

SELECT strftime('%s','now') - strftime('%s','2004-01-01 02:34:56');


Compute the date of the first Tuesday in October for the current year.

SELECT date('now','start of year','+9 months','weekday 2');


Compute the time since the unix epoch in seconds (like strftime('%s','now') except includes fractional part):

SELECT (julianday('now') - 2440587.5)*86400.0;



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值