您好,登錄后才能下訂單哦!
from datetime import timedelta
from datetime import datetime
c = datetime.datetime(2019, 1, 1, 2, 27, 15, 706351)
int(c.strftime('%W')) # 0, 2019年第0周
c.weekday() # 1, 周2,周一為0
## 數(shù)據(jù)庫查詢第幾年第幾周數(shù)據(jù)
a = Leak.query.filter(extract('week', Leak.create_time)==10, extract('year', Leak.create_time)==2019).all()
from sqlalchemy import func
Leak.query.with_entities(
func.count(Leak.id),
extract('year', Leak.create_time),
extract('week', Leak.create_time)
).group_by(
extract('year', Leak.create_time),
extract('week', Leak.create_time)
).order_by(
extract('year', Leak.create_time)
).order_by(
extract('week', Leak.create_time)
).all()
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。