I need to extract the week of the month i.e. 1-5 from the date. I am using below formula in python.
df['Week_no_Month']= ((df.DATE.dt.day-1)//7+1)
Now I want this implemented in SQLite.
I need to extract the week of the month i.e. 1-5 from the date. I am using below formula in python.
df['Week_no_Month']= ((df.DATE.dt.day-1)//7+1)
Now I want this implemented in SQLite.
If you mean that the week is the day divided by 7, then:
select (strftime('%d', dt.day) + 6 / 7)
SQLite is flexible about mixing strings and numbers, so you don't need an explicit conversion -- although you might want to include that:
select (cast(strftime('%d', dt.day) as int) + 6 / 7)