簡體   English   中英

SQLite: - 查找月份中的星期

[英]SQLite: - find week of the month

我需要從日期中提取一個月中的一周,即 1-5。 我在 python 中使用以下公式。

df['Week_no_Month']= ((df.DATE.dt.day-1)//7+1) 

現在我想在 SQLite 中實現它。

如果你的意思是星期是天除以 7,那么:

select (strftime('%d', dt.day) + 6 / 7)

SQLite 可以靈活地混合字符串和數字,因此您不需要顯式轉換 - 盡管您可能希望包含以下內容:

select (cast(strftime('%d', dt.day) as int) + 6 / 7)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM